add mips n32 port (ILP32 ABI for mips64)
based on patch submitted by Jaydeep Patil, with minor changes.
diff --git a/arch/mipsn32/atomic_arch.h b/arch/mipsn32/atomic_arch.h
new file mode 100644
index 0000000..ccc3878
--- /dev/null
+++ b/arch/mipsn32/atomic_arch.h
@@ -0,0 +1,52 @@
+#if __mips_isa_rev < 6
+#define LLSC_M "m"
+#else
+#define LLSC_M "ZC"
+#endif
+
+#define a_ll a_ll
+static inline int a_ll(volatile int *p)
+{
+ int v;
+#if __mips < 2
+ __asm__ __volatile__ (
+ ".set push ; .set mips2\n\t"
+ "ll %0, %1"
+ "\n\t.set pop"
+ : "=r"(v) : "m"(*p));
+#else
+ __asm__ __volatile__ (
+ "ll %0, %1"
+ : "=r"(v) : LLSC_M(*p));
+#endif
+ return v;
+}
+
+#define a_sc a_sc
+static inline int a_sc(volatile int *p, int v)
+{
+ int r;
+#if __mips < 2
+ __asm__ __volatile__ (
+ ".set push ; .set mips2\n\t"
+ "sc %0, %1"
+ "\n\t.set pop"
+ : "=r"(r), "=m"(*p) : "0"(v) : "memory");
+#else
+ __asm__ __volatile__ (
+ "sc %0, %1"
+ : "=r"(r), "="LLSC_M(*p) : "0"(v) : "memory");
+#endif
+ return r;
+}
+
+#define a_barrier a_barrier
+static inline void a_barrier()
+{
+ __asm__ __volatile__ ("sync" : : : "memory");
+}
+
+#define a_pre_llsc a_barrier
+#define a_post_llsc a_barrier
+
+#undef LLSC_M
diff --git a/arch/mipsn32/bits/alltypes.h.in b/arch/mipsn32/bits/alltypes.h.in
new file mode 100644
index 0000000..66ca18a
--- /dev/null
+++ b/arch/mipsn32/bits/alltypes.h.in
@@ -0,0 +1,26 @@
+#define _Addr int
+#define _Int64 long long
+#define _Reg int
+
+TYPEDEF __builtin_va_list va_list;
+TYPEDEF __builtin_va_list __isoc_va_list;
+
+#ifndef __cplusplus
+TYPEDEF int wchar_t;
+#endif
+
+TYPEDEF float float_t;
+TYPEDEF double double_t;
+
+TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
+
+TYPEDEF long time_t;
+TYPEDEF long suseconds_t;
+
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/mipsn32/bits/endian.h b/arch/mipsn32/bits/endian.h
new file mode 100644
index 0000000..5399dcb
--- /dev/null
+++ b/arch/mipsn32/bits/endian.h
@@ -0,0 +1,5 @@
+#if _MIPSEL || __MIPSEL || __MIPSEL__
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
diff --git a/arch/mipsn32/bits/errno.h b/arch/mipsn32/bits/errno.h
new file mode 100644
index 0000000..1bb91e3
--- /dev/null
+++ b/arch/mipsn32/bits/errno.h
@@ -0,0 +1,134 @@
+#define EPERM 1
+#define ENOENT 2
+#define ESRCH 3
+#define EINTR 4
+#define EIO 5
+#define ENXIO 6
+#define E2BIG 7
+#define ENOEXEC 8
+#define EBADF 9
+#define ECHILD 10
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EFAULT 14
+#define ENOTBLK 15
+#define EBUSY 16
+#define EEXIST 17
+#define EXDEV 18
+#define ENODEV 19
+#define ENOTDIR 20
+#define EISDIR 21
+#define EINVAL 22
+#define ENFILE 23
+#define EMFILE 24
+#define ENOTTY 25
+#define ETXTBSY 26
+#define EFBIG 27
+#define ENOSPC 28
+#define ESPIPE 29
+#define EROFS 30
+#define EMLINK 31
+#define EPIPE 32
+#define EDOM 33
+#define ERANGE 34
+#define ENOMSG 35
+#define EIDRM 36
+#define ECHRNG 37
+#define EL2NSYNC 38
+#define EL3HLT 39
+#define EL3RST 40
+#define ELNRNG 41
+#define EUNATCH 42
+#define ENOCSI 43
+#define EL2HLT 44
+#define EDEADLK 45
+#define ENOLCK 46
+#define EBADE 50
+#define EBADR 51
+#define EXFULL 52
+#define ENOANO 53
+#define EBADRQC 54
+#define EBADSLT 55
+#define EDEADLOCK 56
+#define EBFONT 59
+#define ENOSTR 60
+#define ENODATA 61
+#define ETIME 62
+#define ENOSR 63
+#define ENONET 64
+#define ENOPKG 65
+#define EREMOTE 66
+#define ENOLINK 67
+#define EADV 68
+#define ESRMNT 69
+#define ECOMM 70
+#define EPROTO 71
+#define EDOTDOT 73
+#define EMULTIHOP 74
+#define EBADMSG 77
+#define ENAMETOOLONG 78
+#define EOVERFLOW 79
+#define ENOTUNIQ 80
+#define EBADFD 81
+#define EREMCHG 82
+#define ELIBACC 83
+#define ELIBBAD 84
+#define ELIBSCN 85
+#define ELIBMAX 86
+#define ELIBEXEC 87
+#define EILSEQ 88
+#define ENOSYS 89
+#define ELOOP 90
+#define ERESTART 91
+#define ESTRPIPE 92
+#define ENOTEMPTY 93
+#define EUSERS 94
+#define ENOTSOCK 95
+#define EDESTADDRREQ 96
+#define EMSGSIZE 97
+#define EPROTOTYPE 98
+#define ENOPROTOOPT 99
+#define EPROTONOSUPPORT 120
+#define ESOCKTNOSUPPORT 121
+#define EOPNOTSUPP 122
+#define ENOTSUP EOPNOTSUPP
+#define EPFNOSUPPORT 123
+#define EAFNOSUPPORT 124
+#define EADDRINUSE 125
+#define EADDRNOTAVAIL 126
+#define ENETDOWN 127
+#define ENETUNREACH 128
+#define ENETRESET 129
+#define ECONNABORTED 130
+#define ECONNRESET 131
+#define ENOBUFS 132
+#define EISCONN 133
+#define ENOTCONN 134
+#define EUCLEAN 135
+#define ENOTNAM 137
+#define ENAVAIL 138
+#define EISNAM 139
+#define EREMOTEIO 140
+#define ESHUTDOWN 143
+#define ETOOMANYREFS 144
+#define ETIMEDOUT 145
+#define ECONNREFUSED 146
+#define EHOSTDOWN 147
+#define EHOSTUNREACH 148
+#define EWOULDBLOCK EAGAIN
+#define EALREADY 149
+#define EINPROGRESS 150
+#define ESTALE 151
+#define ECANCELED 158
+#define ENOMEDIUM 159
+#define EMEDIUMTYPE 160
+#define ENOKEY 161
+#define EKEYEXPIRED 162
+#define EKEYREVOKED 163
+#define EKEYREJECTED 164
+#define EOWNERDEAD 165
+#define ENOTRECOVERABLE 166
+#define ERFKILL 167
+#define EHWPOISON 168
+#define EDQUOT 1133
diff --git a/arch/mipsn32/bits/fcntl.h b/arch/mipsn32/bits/fcntl.h
new file mode 100644
index 0000000..9fd8c23
--- /dev/null
+++ b/arch/mipsn32/bits/fcntl.h
@@ -0,0 +1,40 @@
+#define O_CREAT 0400
+#define O_EXCL 02000
+#define O_NOCTTY 04000
+#define O_TRUNC 01000
+#define O_APPEND 0010
+#define O_NONBLOCK 0200
+#define O_DSYNC 0020
+#define O_SYNC 040020
+#define O_RSYNC 040020
+#define O_DIRECTORY 0200000
+#define O_NOFOLLOW 0400000
+#define O_CLOEXEC 02000000
+
+#define O_ASYNC 010000
+#define O_DIRECT 0100000
+#define O_LARGEFILE 020000
+#define O_NOATIME 01000000
+#define O_PATH 010000000
+#define O_TMPFILE 020200000
+#define O_NDELAY O_NONBLOCK
+
+#define F_DUPFD 0
+#define F_GETFD 1
+#define F_SETFD 2
+#define F_GETFL 3
+#define F_SETFL 4
+
+#define F_SETOWN 24
+#define F_GETOWN 23
+#define F_SETSIG 10
+#define F_GETSIG 11
+
+#define F_GETLK 33
+#define F_SETLK 34
+#define F_SETLKW 35
+
+#define F_SETOWN_EX 15
+#define F_GETOWN_EX 16
+
+#define F_GETOWNER_UIDS 17
diff --git a/arch/mipsn32/bits/fenv.h b/arch/mipsn32/bits/fenv.h
new file mode 100644
index 0000000..589e71c
--- /dev/null
+++ b/arch/mipsn32/bits/fenv.h
@@ -0,0 +1,25 @@
+#ifdef __mips_soft_float
+#define FE_ALL_EXCEPT 0
+#define FE_TONEAREST 0
+#else
+#define FE_INEXACT 4
+#define FE_UNDERFLOW 8
+#define FE_OVERFLOW 16
+#define FE_DIVBYZERO 32
+#define FE_INVALID 64
+
+#define FE_ALL_EXCEPT 124
+
+#define FE_TONEAREST 0
+#define FE_TOWARDZERO 1
+#define FE_UPWARD 2
+#define FE_DOWNWARD 3
+#endif
+
+typedef unsigned short fexcept_t;
+
+typedef struct {
+ unsigned __cw;
+} fenv_t;
+
+#define FE_DFL_ENV ((const fenv_t *) -1)
diff --git a/arch/mipsn32/bits/float.h b/arch/mipsn32/bits/float.h
new file mode 100644
index 0000000..719c790
--- /dev/null
+++ b/arch/mipsn32/bits/float.h
@@ -0,0 +1,16 @@
+#define FLT_EVAL_METHOD 0
+
+#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
+#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
+#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
+#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
+
+#define LDBL_MANT_DIG 113
+#define LDBL_MIN_EXP (-16381)
+#define LDBL_MAX_EXP 16384
+
+#define LDBL_DIG 33
+#define LDBL_MIN_10_EXP (-4931)
+#define LDBL_MAX_10_EXP 4932
+
+#define DECIMAL_DIG 36
diff --git a/arch/mipsn32/bits/ioctl.h b/arch/mipsn32/bits/ioctl.h
new file mode 100644
index 0000000..041be56
--- /dev/null
+++ b/arch/mipsn32/bits/ioctl.h
@@ -0,0 +1,210 @@
+#define _IOC(a,b,c,d) ( ((a)<<29) | ((b)<<8) | (c) | ((d)<<16) )
+#define _IOC_NONE 1U
+#define _IOC_READ 2U
+#define _IOC_WRITE 4U
+
+#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+
+#define TCGETA 0x5401
+#define TCSETA 0x5402
+#define TCSETAW 0x5403
+#define TCSETAF 0x5404
+#define TCSBRK 0x5405
+#define TCXONC 0x5406
+#define TCFLSH 0x5407
+#define TCGETS 0x540D
+#define TCSETS 0x540E
+#define TCSETSW 0x540F
+#define TCSETSF 0x5410
+
+#define TIOCEXCL 0x740D
+#define TIOCNXCL 0x740E
+#define TIOCOUTQ 0x7472
+#define TIOCSTI 0x5472
+#define TIOCMGET 0x741D
+#define TIOCMBIS 0x741B
+#define TIOCMBIC 0x741C
+#define TIOCMSET 0x741D
+
+#define TIOCPKT 0x5470
+#define TIOCSWINSZ _IOW('t', 103, struct winsize)
+#define TIOCGWINSZ _IOR('t', 104, struct winsize)
+#define TIOCNOTTY 0x5471
+#define TIOCSETD 0x7401
+#define TIOCGETD 0x7400
+
+#define FIOCLEX 0x6601
+#define FIONCLEX 0x6602
+#define FIOASYNC 0x667D
+#define FIONBIO 0x667E
+#define FIOQSIZE 0x667F
+
+#define TIOCGLTC 0x7474
+#define TIOCSLTC 0x7475
+#define TIOCSPGRP _IOW('t', 118, int)
+#define TIOCGPGRP _IOR('t', 119, int)
+#define TIOCCONS _IOW('t', 120, int)
+
+#define FIONREAD 0x467F
+#define TIOCINQ FIONREAD
+
+#define TIOCGETP 0x7408
+#define TIOCSETP 0x7409
+#define TIOCSETN 0x740A
+
+#define TIOCSBRK 0x5427
+#define TIOCCBRK 0x5428
+#define TIOCGSID 0x7416
+#define TIOCGPTN _IOR('T', 0x30, unsigned int)
+#define TIOCSPTLCK _IOW('T', 0x31, int)
+
+#define TIOCSCTTY 0x5480
+#define TIOCGSOFTCAR 0x5481
+#define TIOCSSOFTCAR 0x5482
+#define TIOCLINUX 0x5483
+#define TIOCGSERIAL 0x5484
+#define TIOCSSERIAL 0x5485
+#define TCSBRKP 0x5486
+
+#define TIOCSERCONFIG 0x5488
+#define TIOCSERGWILD 0x5489
+#define TIOCSERSWILD 0x548A
+#define TIOCGLCKTRMIOS 0x548B
+#define TIOCSLCKTRMIOS 0x548C
+#define TIOCSERGSTRUCT 0x548D
+#define TIOCSERGETLSR 0x548E
+#define TIOCSERGETMULTI 0x548F
+#define TIOCSERSETMULTI 0x5490
+#define TIOCMIWAIT 0x5491
+#define TIOCGICOUNT 0x5492
+#define TIOCGHAYESESP 0x5493
+#define TIOCSHAYESESP 0x5494
+
+#define TIOCTTYGSTRUCT 0x5426
+#define TCGETX 0x5432
+#define TCSETX 0x5433
+#define TCSETXF 0x5434
+#define TCSETXW 0x5435
+
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+#define TIOCPKT_IOCTL 64
+
+#define TIOCSER_TEMT 0x01
+
+struct winsize {
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
+};
+
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x008
+#define TIOCM_SR 0x010
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RNG 0x080
+#define TIOCM_DSR 0x100
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_OUT1 0x2000
+#define TIOCM_OUT2 0x4000
+#define TIOCM_LOOP 0x8000
+#define TIOCM_MODEM_BITS TIOCM_OUT2
+
+#define N_TTY 0
+#define N_SLIP 1
+#define N_MOUSE 2
+#define N_PPP 3
+#define N_STRIP 4
+#define N_AX25 5
+#define N_X25 6
+#define N_6PACK 7
+#define N_MASC 8
+#define N_R3964 9
+#define N_PROFIBUS_FDL 10
+#define N_IRDA 11
+#define N_SMSBLOCK 12
+#define N_HDLC 13
+#define N_SYNC_PPP 14
+#define N_HCI 15
+
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906
+
+#define SIOCADDRT 0x890B
+#define SIOCDELRT 0x890C
+#define SIOCRTMSG 0x890D
+
+#define SIOCGIFNAME 0x8910
+#define SIOCSIFLINK 0x8911
+#define SIOCGIFCONF 0x8912
+#define SIOCGIFFLAGS 0x8913
+#define SIOCSIFFLAGS 0x8914
+#define SIOCGIFADDR 0x8915
+#define SIOCSIFADDR 0x8916
+#define SIOCGIFDSTADDR 0x8917
+#define SIOCSIFDSTADDR 0x8918
+#define SIOCGIFBRDADDR 0x8919
+#define SIOCSIFBRDADDR 0x891a
+#define SIOCGIFNETMASK 0x891b
+#define SIOCSIFNETMASK 0x891c
+#define SIOCGIFMETRIC 0x891d
+#define SIOCSIFMETRIC 0x891e
+#define SIOCGIFMEM 0x891f
+#define SIOCSIFMEM 0x8920
+#define SIOCGIFMTU 0x8921
+#define SIOCSIFMTU 0x8922
+#define SIOCSIFHWADDR 0x8924
+#define SIOCGIFENCAP 0x8925
+#define SIOCSIFENCAP 0x8926
+#define SIOCGIFHWADDR 0x8927
+#define SIOCGIFSLAVE 0x8929
+#define SIOCSIFSLAVE 0x8930
+#define SIOCADDMULTI 0x8931
+#define SIOCDELMULTI 0x8932
+#define SIOCGIFINDEX 0x8933
+#define SIOGIFINDEX SIOCGIFINDEX
+#define SIOCSIFPFLAGS 0x8934
+#define SIOCGIFPFLAGS 0x8935
+#define SIOCDIFADDR 0x8936
+#define SIOCSIFHWBROADCAST 0x8937
+#define SIOCGIFCOUNT 0x8938
+
+#define SIOCGIFBR 0x8940
+#define SIOCSIFBR 0x8941
+
+#define SIOCGIFTXQLEN 0x8942
+#define SIOCSIFTXQLEN 0x8943
+
+#define SIOCDARP 0x8953
+#define SIOCGARP 0x8954
+#define SIOCSARP 0x8955
+
+#define SIOCDRARP 0x8960
+#define SIOCGRARP 0x8961
+#define SIOCSRARP 0x8962
+
+#define SIOCGIFMAP 0x8970
+#define SIOCSIFMAP 0x8971
+
+#define SIOCADDDLCI 0x8980
+#define SIOCDELDLCI 0x8981
+
+#define SIOCDEVPRIVATE 0x89F0
+#define SIOCPROTOPRIVATE 0x89E0
diff --git a/arch/mipsn32/bits/limits.h b/arch/mipsn32/bits/limits.h
new file mode 100644
index 0000000..fbc6d23
--- /dev/null
+++ b/arch/mipsn32/bits/limits.h
@@ -0,0 +1,7 @@
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define LONG_BIT 32
+#endif
+
+#define LONG_MAX 0x7fffffffL
+#define LLONG_MAX 0x7fffffffffffffffLL
diff --git a/arch/mipsn32/bits/mman.h b/arch/mipsn32/bits/mman.h
new file mode 100644
index 0000000..c68aea8
--- /dev/null
+++ b/arch/mipsn32/bits/mman.h
@@ -0,0 +1,24 @@
+#undef MAP_ANON
+#define MAP_ANON 0x800
+#undef MAP_NORESERVE
+#define MAP_NORESERVE 0x0400
+#undef MAP_GROWSDOWN
+#define MAP_GROWSDOWN 0x1000
+#undef MAP_DENYWRITE
+#define MAP_DENYWRITE 0x2000
+#undef MAP_EXECUTABLE
+#define MAP_EXECUTABLE 0x4000
+#undef MAP_LOCKED
+#define MAP_LOCKED 0x8000
+#undef MAP_POPULATE
+#define MAP_POPULATE 0x10000
+#undef MAP_NONBLOCK
+#define MAP_NONBLOCK 0x20000
+#undef MAP_STACK
+#define MAP_STACK 0x40000
+#undef MAP_HUGETLB
+#define MAP_HUGETLB 0x80000
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#undef MADV_SOFT_OFFLINE
+#endif
diff --git a/arch/mipsn32/bits/msg.h b/arch/mipsn32/bits/msg.h
new file mode 100644
index 0000000..bfe2b3a
--- /dev/null
+++ b/arch/mipsn32/bits/msg.h
@@ -0,0 +1,25 @@
+struct msqid_ds
+{
+ struct ipc_perm msg_perm;
+#if _MIPSEL || __MIPSEL || __MIPSEL__
+ time_t msg_stime;
+ int __unused1;
+ time_t msg_rtime;
+ int __unused2;
+ time_t msg_ctime;
+ int __unused3;
+#else
+ int __unused1;
+ time_t msg_stime;
+ int __unused2;
+ time_t msg_rtime;
+ int __unused3;
+ time_t msg_ctime;
+#endif
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ unsigned long __unused[2];
+};
diff --git a/arch/mipsn32/bits/poll.h b/arch/mipsn32/bits/poll.h
new file mode 100644
index 0000000..b0b1ed6
--- /dev/null
+++ b/arch/mipsn32/bits/poll.h
@@ -0,0 +1,2 @@
+#define POLLWRNORM POLLOUT
+#define POLLWRBAND 0x100
diff --git a/arch/mipsn32/bits/posix.h b/arch/mipsn32/bits/posix.h
new file mode 100644
index 0000000..30a3871
--- /dev/null
+++ b/arch/mipsn32/bits/posix.h
@@ -0,0 +1,2 @@
+#define _POSIX_V6_ILP32_OFFBIG 1
+#define _POSIX_V7_ILP32_OFFBIG 1
diff --git a/arch/mipsn32/bits/reg.h b/arch/mipsn32/bits/reg.h
new file mode 100644
index 0000000..a3f63ac
--- /dev/null
+++ b/arch/mipsn32/bits/reg.h
@@ -0,0 +1,47 @@
+#undef __WORDSIZE
+#define __WORDSIZE 64
+
+#define EF_R0 0
+#define EF_R1 1
+#define EF_R2 2
+#define EF_R3 3
+#define EF_R4 4
+#define EF_R5 5
+#define EF_R6 6
+#define EF_R7 7
+#define EF_R8 8
+#define EF_R9 9
+#define EF_R10 10
+#define EF_R11 11
+#define EF_R12 12
+#define EF_R13 13
+#define EF_R14 14
+#define EF_R15 15
+#define EF_R16 16
+#define EF_R17 17
+#define EF_R18 18
+#define EF_R19 19
+#define EF_R20 20
+#define EF_R21 21
+#define EF_R22 22
+#define EF_R23 23
+#define EF_R24 24
+#define EF_R25 25
+
+#define EF_R26 26
+#define EF_R27 27
+#define EF_R28 28
+#define EF_R29 29
+#define EF_R30 30
+#define EF_R31 31
+
+#define EF_LO 32
+#define EF_HI 33
+
+#define EF_CP0_EPC 34
+#define EF_CP0_BADVADDR 35
+#define EF_CP0_STATUS 36
+#define EF_CP0_CAUSE 37
+#define EF_UNUSED0 38
+
+#define EF_SIZE 304
diff --git a/arch/mipsn32/bits/resource.h b/arch/mipsn32/bits/resource.h
new file mode 100644
index 0000000..414a405
--- /dev/null
+++ b/arch/mipsn32/bits/resource.h
@@ -0,0 +1,5 @@
+#define RLIMIT_NOFILE 5
+#define RLIMIT_AS 6
+#define RLIMIT_RSS 7
+#define RLIMIT_NPROC 8
+#define RLIMIT_MEMLOCK 9
diff --git a/arch/mipsn32/bits/sem.h b/arch/mipsn32/bits/sem.h
new file mode 100644
index 0000000..e46ced9
--- /dev/null
+++ b/arch/mipsn32/bits/sem.h
@@ -0,0 +1,14 @@
+struct semid_ds {
+ struct ipc_perm sem_perm;
+ time_t sem_otime;
+ time_t sem_ctime;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned short sem_nsems;
+ char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+#else
+ char __sem_nsems_pad[sizeof(time_t)-sizeof(short)];
+ unsigned short sem_nsems;
+#endif
+ time_t __unused3;
+ time_t __unused4;
+};
diff --git a/arch/mipsn32/bits/setjmp.h b/arch/mipsn32/bits/setjmp.h
new file mode 100644
index 0000000..4d93267
--- /dev/null
+++ b/arch/mipsn32/bits/setjmp.h
@@ -0,0 +1 @@
+typedef unsigned long long __jmp_buf[23];
diff --git a/arch/mipsn32/bits/shm.h b/arch/mipsn32/bits/shm.h
new file mode 100644
index 0000000..8d19378
--- /dev/null
+++ b/arch/mipsn32/bits/shm.h
@@ -0,0 +1,24 @@
+#define SHMLBA 4096
+
+struct shmid_ds {
+ struct ipc_perm shm_perm;
+ size_t shm_segsz;
+ time_t shm_atime;
+ time_t shm_dtime;
+ time_t shm_ctime;
+ pid_t shm_cpid;
+ pid_t shm_lpid;
+ unsigned long shm_nattch;
+ unsigned long __pad1;
+ unsigned long __pad2;
+};
+
+struct shminfo {
+ unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
+};
+
+struct shm_info {
+ int __used_ids;
+ unsigned long shm_tot, shm_rss, shm_swp;
+ unsigned long __swap_attempts, __swap_successes;
+};
diff --git a/arch/mipsn32/bits/signal.h b/arch/mipsn32/bits/signal.h
new file mode 100644
index 0000000..c31ad07
--- /dev/null
+++ b/arch/mipsn32/bits/signal.h
@@ -0,0 +1,143 @@
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+#endif
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+typedef unsigned long long greg_t, gregset_t[32];
+
+typedef struct {
+ union {
+ double fp_dregs[32];
+ struct {
+ float _fp_fregs;
+ unsigned _fp_pad;
+ } fp_fregs[32];
+ } fp_r;
+} fpregset_t;
+
+struct sigcontext {
+ unsigned long long sc_regs[32];
+ unsigned long long sc_fpregs[32];
+ unsigned long long sc_mdhi;
+ unsigned long long sc_hi1;
+ unsigned long long sc_hi2;
+ unsigned long long sc_hi3;
+ unsigned long long sc_mdlo;
+ unsigned long long sc_lo1;
+ unsigned long long sc_lo2;
+ unsigned long long sc_lo3;
+ unsigned long long sc_pc;
+ unsigned int sc_fpc_csr;
+ unsigned int sc_used_math;
+ unsigned int sc_dsp;
+ unsigned int sc_reserved;
+};
+
+typedef struct {
+ gregset_t gregs;
+ fpregset_t fpregs;
+ greg_t mdhi;
+ greg_t hi1;
+ greg_t hi2;
+ greg_t hi3;
+ greg_t mdlo;
+ greg_t lo1;
+ greg_t lo2;
+ greg_t lo3;
+ greg_t pc;
+ unsigned int fpc_csr;
+ unsigned int used_math;
+ unsigned int dsp;
+ unsigned int reserved;
+} mcontext_t;
+
+#else
+typedef struct {
+ unsigned long long __mc1[32];
+ double __mc2[32];
+ unsigned long long __mc3[9];
+ unsigned __mc4[4];
+} mcontext_t;
+#endif
+
+struct sigaltstack {
+ void *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+};
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+} ucontext_t;
+
+#define SA_NOCLDSTOP 1
+#define SA_NOCLDWAIT 0x10000
+#define SA_SIGINFO 8
+#define SA_ONSTACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_NODEFER 0x40000000
+#define SA_RESETHAND 0x80000000
+#define SA_RESTORER 0x04000000
+
+#undef SIG_BLOCK
+#undef SIG_UNBLOCK
+#undef SIG_SETMASK
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
+#undef SI_ASYNCIO
+#undef SI_MESGQ
+#undef SI_TIMER
+#define SI_ASYNCIO (-2)
+#define SI_MESGQ (-4)
+#define SI_TIMER (-3)
+
+#define __SI_SWAP_ERRNO_CODE
+
+#endif
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT SIGABRT
+#define SIGSTKFLT 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGBUS 10
+#define SIGSEGV 11
+#define SIGSYS 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGUSR1 16
+#define SIGUSR2 17
+#define SIGCHLD 18
+#define SIGPWR 19
+#define SIGWINCH 20
+#define SIGURG 21
+#define SIGIO 22
+#define SIGPOLL SIGIO
+#define SIGSTOP 23
+#define SIGTSTP 24
+#define SIGCONT 25
+#define SIGTTIN 26
+#define SIGTTOU 27
+#define SIGVTALRM 28
+#define SIGPROF 29
+#define SIGXCPU 30
+#define SIGXFSZ 31
+#define SIGUNUSED SIGSYS
+
+#define _NSIG 128
diff --git a/arch/mipsn32/bits/socket.h b/arch/mipsn32/bits/socket.h
new file mode 100644
index 0000000..191ebdb
--- /dev/null
+++ b/arch/mipsn32/bits/socket.h
@@ -0,0 +1,52 @@
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+struct cmsghdr {
+ socklen_t cmsg_len;
+ int cmsg_level;
+ int cmsg_type;
+};
+
+#define SOCK_STREAM 2
+#define SOCK_DGRAM 1
+
+#define SOL_SOCKET 65535
+
+#define SO_DEBUG 1
+
+#define SO_REUSEADDR 0x0004
+#define SO_KEEPALIVE 0x0008
+#define SO_DONTROUTE 0x0010
+#define SO_BROADCAST 0x0020
+#define SO_LINGER 0x0080
+#define SO_OOBINLINE 0x0100
+#define SO_REUSEPORT 0x0200
+#define SO_SNDBUF 0x1001
+#define SO_RCVBUF 0x1002
+#define SO_SNDLOWAT 0x1003
+#define SO_RCVLOWAT 0x1004
+#define SO_RCVTIMEO 0x1006
+#define SO_SNDTIMEO 0x1005
+#define SO_ERROR 0x1007
+#define SO_TYPE 0x1008
+#define SO_ACCEPTCONN 0x1009
+#define SO_PROTOCOL 0x1028
+#define SO_DOMAIN 0x1029
+
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_BSDCOMPAT 14
+#define SO_PASSCRED 17
+#define SO_PEERCRED 18
+#define SO_SNDBUFFORCE 31
+#define SO_RCVBUFFORCE 33
+
+#define SOCK_NONBLOCK 0200
+#define SOCK_CLOEXEC 02000000
diff --git a/arch/mipsn32/bits/stat.h b/arch/mipsn32/bits/stat.h
new file mode 100644
index 0000000..f4d1df8
--- /dev/null
+++ b/arch/mipsn32/bits/stat.h
@@ -0,0 +1,22 @@
+#include <string.h>
+#include <bits/alltypes.h>
+
+struct stat {
+ dev_t st_dev;
+ long __pad1[2];
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ long __pad2[2];
+ off_t st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ blksize_t st_blksize;
+ long __pad3;
+ blkcnt_t st_blocks;
+ long __pad4[14];
+};
diff --git a/arch/mipsn32/bits/statfs.h b/arch/mipsn32/bits/statfs.h
new file mode 100644
index 0000000..a73bd54
--- /dev/null
+++ b/arch/mipsn32/bits/statfs.h
@@ -0,0 +1,8 @@
+struct statfs {
+ unsigned long f_type, f_bsize, f_frsize;
+ fsblkcnt_t f_blocks, f_bfree;
+ fsfilcnt_t f_files, f_ffree;
+ fsblkcnt_t f_bavail;
+ fsid_t f_fsid;
+ unsigned long f_namelen, f_flags, f_spare[5];
+};
diff --git a/arch/mipsn32/bits/stdint.h b/arch/mipsn32/bits/stdint.h
new file mode 100644
index 0000000..d1b2712
--- /dev/null
+++ b/arch/mipsn32/bits/stdint.h
@@ -0,0 +1,20 @@
+typedef int32_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef uint32_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST32_MIN INT32_MIN
+
+#define INT_FAST16_MAX INT32_MAX
+#define INT_FAST32_MAX INT32_MAX
+
+#define UINT_FAST16_MAX UINT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+#define SIZE_MAX UINT32_MAX
diff --git a/arch/mipsn32/bits/syscall.h b/arch/mipsn32/bits/syscall.h
new file mode 100644
index 0000000..09e4a25
--- /dev/null
+++ b/arch/mipsn32/bits/syscall.h
@@ -0,0 +1,649 @@
+#define __NR_read 6000
+#define __NR_write 6001
+#define __NR_open 6002
+#define __NR_close 6003
+#define __NR_stat 6004
+#define __NR_fstat 6005
+#define __NR_lstat 6006
+#define __NR_poll 6007
+#define __NR_lseek 6008
+#define __NR_mmap 6009
+#define __NR_mprotect 6010
+#define __NR_munmap 6011
+#define __NR_brk 6012
+#define __NR_rt_sigaction 6013
+#define __NR_rt_sigprocmask 6014
+#define __NR_ioctl 6015
+#define __NR_pread64 6016
+#define __NR_pwrite64 6017
+#define __NR_readv 6018
+#define __NR_writev 6019
+#define __NR_access 6020
+#define __NR_pipe 6021
+#define __NR__newselect 6022
+#define __NR_sched_yield 6023
+#define __NR_mremap 6024
+#define __NR_msync 6025
+#define __NR_mincore 6026
+#define __NR_madvise 6027
+#define __NR_shmget 6028
+#define __NR_shmat 6029
+#define __NR_shmctl 6030
+#define __NR_dup 6031
+#define __NR_dup2 6032
+#define __NR_pause 6033
+#define __NR_nanosleep 6034
+#define __NR_getitimer 6035
+#define __NR_setitimer 6036
+#define __NR_alarm 6037
+#define __NR_getpid 6038
+#define __NR_sendfile 6039
+#define __NR_socket 6040
+#define __NR_connect 6041
+#define __NR_accept 6042
+#define __NR_sendto 6043
+#define __NR_recvfrom 6044
+#define __NR_sendmsg 6045
+#define __NR_recvmsg 6046
+#define __NR_shutdown 6047
+#define __NR_bind 6048
+#define __NR_listen 6049
+#define __NR_getsockname 6050
+#define __NR_getpeername 6051
+#define __NR_socketpair 6052
+#define __NR_setsockopt 6053
+#define __NR_getsockopt 6054
+#define __NR_clone 6055
+#define __NR_fork 6056
+#define __NR_execve 6057
+#define __NR_exit 6058
+#define __NR_wait4 6059
+#define __NR_kill 6060
+#define __NR_uname 6061
+#define __NR_semget 6062
+#define __NR_semop 6063
+#define __NR_semctl 6064
+#define __NR_shmdt 6065
+#define __NR_msgget 6066
+#define __NR_msgsnd 6067
+#define __NR_msgrcv 6068
+#define __NR_msgctl 6069
+#define __NR_fcntl 6070
+#define __NR_flock 6071
+#define __NR_fsync 6072
+#define __NR_fdatasync 6073
+#define __NR_truncate 6074
+#define __NR_ftruncate 6075
+#define __NR_getdents 6076
+#define __NR_getcwd 6077
+#define __NR_chdir 6078
+#define __NR_fchdir 6079
+#define __NR_rename 6080
+#define __NR_mkdir 6081
+#define __NR_rmdir 6082
+#define __NR_creat 6083
+#define __NR_link 6084
+#define __NR_unlink 6085
+#define __NR_symlink 6086
+#define __NR_readlink 6087
+#define __NR_chmod 6088
+#define __NR_fchmod 6089
+#define __NR_chown 6090
+#define __NR_fchown 6091
+#define __NR_lchown 6092
+#define __NR_umask 6093
+#define __NR_gettimeofday 6094
+#define __NR_getrlimit 6095
+#define __NR_getrusage 6096
+#define __NR_sysinfo 6097
+#define __NR_times 6098
+#define __NR_ptrace 6099
+#define __NR_getuid 6100
+#define __NR_syslog 6101
+#define __NR_getgid 6102
+#define __NR_setuid 6103
+#define __NR_setgid 6104
+#define __NR_geteuid 6105
+#define __NR_getegid 6106
+#define __NR_setpgid 6107
+#define __NR_getppid 6108
+#define __NR_getpgrp 6109
+#define __NR_setsid 6110
+#define __NR_setreuid 6111
+#define __NR_setregid 6112
+#define __NR_getgroups 6113
+#define __NR_setgroups 6114
+#define __NR_setresuid 6115
+#define __NR_getresuid 6116
+#define __NR_setresgid 6117
+#define __NR_getresgid 6118
+#define __NR_getpgid 6119
+#define __NR_setfsuid 6120
+#define __NR_setfsgid 6121
+#define __NR_getsid 6122
+#define __NR_capget 6123
+#define __NR_capset 6124
+#define __NR_rt_sigpending 6125
+#define __NR_rt_sigtimedwait 6126
+#define __NR_rt_sigqueueinfo 6127
+#define __NR_rt_sigsuspend 6128
+#define __NR_sigaltstack 6129
+#define __NR_utime 6130
+#define __NR_mknod 6131
+#define __NR_personality 6132
+#define __NR_ustat 6133
+#define __NR_statfs 6134
+#define __NR_fstatfs 6135
+#define __NR_sysfs 6136
+#define __NR_getpriority 6137
+#define __NR_setpriority 6138
+#define __NR_sched_setparam 6139
+#define __NR_sched_getparam 6140
+#define __NR_sched_setscheduler 6141
+#define __NR_sched_getscheduler 6142
+#define __NR_sched_get_priority_max 6143
+#define __NR_sched_get_priority_min 6144
+#define __NR_sched_rr_get_interval 6145
+#define __NR_mlock 6146
+#define __NR_munlock 6147
+#define __NR_mlockall 6148
+#define __NR_munlockall 6149
+#define __NR_vhangup 6150
+#define __NR_pivot_root 6151
+#define __NR__sysctl 6152
+#define __NR_prctl 6153
+#define __NR_adjtimex 6154
+#define __NR_setrlimit 6155
+#define __NR_chroot 6156
+#define __NR_sync 6157
+#define __NR_acct 6158
+#define __NR_settimeofday 6159
+#define __NR_mount 6160
+#define __NR_umount2 6161
+#define __NR_swapon 6162
+#define __NR_swapoff 6163
+#define __NR_reboot 6164
+#define __NR_sethostname 6165
+#define __NR_setdomainname 6166
+#define __NR_create_module 6167
+#define __NR_init_module 6168
+#define __NR_delete_module 6169
+#define __NR_get_kernel_syms 6170
+#define __NR_query_module 6171
+#define __NR_quotactl 6172
+#define __NR_nfsservctl 6173
+#define __NR_getpmsg 6174
+#define __NR_putpmsg 6175
+#define __NR_afs_syscall 6176
+#define __NR_reserved177 6177
+#define __NR_gettid 6178
+#define __NR_readahead 6179
+#define __NR_setxattr 6180
+#define __NR_lsetxattr 6181
+#define __NR_fsetxattr 6182
+#define __NR_getxattr 6183
+#define __NR_lgetxattr 6184
+#define __NR_fgetxattr 6185
+#define __NR_listxattr 6186
+#define __NR_llistxattr 6187
+#define __NR_flistxattr 6188
+#define __NR_removexattr 6189
+#define __NR_lremovexattr 6190
+#define __NR_fremovexattr 6191
+#define __NR_tkill 6192
+#define __NR_reserved193 6193
+#define __NR_futex 6194
+#define __NR_sched_setaffinity 6195
+#define __NR_sched_getaffinity 6196
+#define __NR_cacheflush 6197
+#define __NR_cachectl 6198
+#define __NR_sysmips 6199
+#define __NR_io_setup 6200
+#define __NR_io_destroy 6201
+#define __NR_io_getevents 6202
+#define __NR_io_submit 6203
+#define __NR_io_cancel 6204
+#define __NR_exit_group 6205
+#define __NR_lookup_dcookie 6206
+#define __NR_epoll_create 6207
+#define __NR_epoll_ctl 6208
+#define __NR_epoll_wait 6209
+#define __NR_remap_file_pages 6210
+#define __NR_rt_sigreturn 6211
+#define __NR_fcntl64 6212
+#define __NR_set_tid_address 6213
+#define __NR_restart_syscall 6214
+#define __NR_semtimedop 6215
+#define __NR_fadvise64 6216
+#define __NR_statfs64 6217
+#define __NR_fstatfs64 6218
+#define __NR_sendfile64 6219
+#define __NR_timer_create 6220
+#define __NR_timer_settime 6221
+#define __NR_timer_gettime 6222
+#define __NR_timer_getoverrun 6223
+#define __NR_timer_delete 6224
+#define __NR_clock_settime 6225
+#define __NR_clock_gettime 6226
+#define __NR_clock_getres 6227
+#define __NR_clock_nanosleep 6228
+#define __NR_tgkill 6229
+#define __NR_utimes 6230
+#define __NR_mbind 6231
+#define __NR_get_mempolicy 6232
+#define __NR_set_mempolicy 6233
+#define __NR_mq_open 6234
+#define __NR_mq_unlink 6235
+#define __NR_mq_timedsend 6236
+#define __NR_mq_timedreceive 6237
+#define __NR_mq_notify 6238
+#define __NR_mq_getsetattr 6239
+#define __NR_vserver 6240
+#define __NR_waitid 6241
+#define __NR_add_key 6243
+#define __NR_request_key 6244
+#define __NR_keyctl 6245
+#define __NR_set_thread_area 6246
+#define __NR_inotify_init 6247
+#define __NR_inotify_add_watch 6248
+#define __NR_inotify_rm_watch 6249
+#define __NR_migrate_pages 6250
+#define __NR_openat 6251
+#define __NR_mkdirat 6252
+#define __NR_mknodat 6253
+#define __NR_fchownat 6254
+#define __NR_futimesat 6255
+#define __NR_fstatat 6256
+#define __NR_unlinkat 6257
+#define __NR_renameat 6258
+#define __NR_linkat 6259
+#define __NR_symlinkat 6260
+#define __NR_readlinkat 6261
+#define __NR_fchmodat 6262
+#define __NR_faccessat 6263
+#define __NR_pselect6 6264
+#define __NR_ppoll 6265
+#define __NR_unshare 6266
+#define __NR_splice 6267
+#define __NR_sync_file_range 6268
+#define __NR_tee 6269
+#define __NR_vmsplice 6270
+#define __NR_move_pages 6271
+#define __NR_set_robust_list 6272
+#define __NR_get_robust_list 6273
+#define __NR_kexec_load 6274
+#define __NR_getcpu 6275
+#define __NR_epoll_pwait 6276
+#define __NR_ioprio_set 6277
+#define __NR_ioprio_get 6278
+#define __NR_utimensat 6279
+#define __NR_signalfd 6280
+#define __NR_timerfd 6281
+#define __NR_eventfd 6282
+#define __NR_fallocate 6283
+#define __NR_timerfd_create 6284
+#define __NR_timerfd_gettime 6285
+#define __NR_timerfd_settime 6286
+#define __NR_signalfd4 6287
+#define __NR_eventfd2 6288
+#define __NR_epoll_create1 6289
+#define __NR_dup3 6290
+#define __NR_pipe2 6291
+#define __NR_inotify_init1 6292
+#define __NR_preadv 6293
+#define __NR_pwritev 6294
+#define __NR_rt_tgsigqueueinfo 6295
+#define __NR_perf_event_open 6296
+#define __NR_accept4 6297
+#define __NR_recvmmsg 6298
+#define __NR_getdents64 6299
+#define __NR_fanotify_init 6300
+#define __NR_fanotify_mark 6301
+#define __NR_prlimit64 6302
+#define __NR_name_to_handle_at 6303
+#define __NR_open_by_handle_at 6304
+#define __NR_clock_adjtime 6305
+#define __NR_syncfs 6306
+#define __NR_sendmmsg 6307
+#define __NR_setns 6308
+#define __NR_process_vm_readv 6309
+#define __NR_process_vm_writev 6310
+#define __NR_kcmp 6311
+#define __NR_finit_module 6312
+#define __NR_sched_setattr 6313
+#define __NR_sched_getattr 6314
+#define __NR_renameat2 6315
+#define __NR_seccomp 6316
+#define __NR_getrandom 6317
+#define __NR_memfd_create 6318
+#define __NR_bpf 6319
+#define __NR_execveat 6320
+#define __NR_userfaultfd 6321
+#define __NR_membarrier 6322
+#define __NR_mlock2 6323
+#define __NR_copy_file_range 6324
+
+#define SYS_read 6000
+#define SYS_write 6001
+#define SYS_open 6002
+#define SYS_close 6003
+#define SYS_stat 6004
+#define SYS_fstat 6005
+#define SYS_lstat 6006
+#define SYS_poll 6007
+#define SYS_lseek 6008
+#define SYS_mmap 6009
+#define SYS_mprotect 6010
+#define SYS_munmap 6011
+#define SYS_brk 6012
+#define SYS_rt_sigaction 6013
+#define SYS_rt_sigprocmask 6014
+#define SYS_ioctl 6015
+#define SYS_pread64 6016
+#define SYS_pwrite64 6017
+#define SYS_readv 6018
+#define SYS_writev 6019
+#define SYS_access 6020
+#define SYS_pipe 6021
+#define SYS__newselect 6022
+#define SYS_sched_yield 6023
+#define SYS_mremap 6024
+#define SYS_msync 6025
+#define SYS_mincore 6026
+#define SYS_madvise 6027
+#define SYS_shmget 6028
+#define SYS_shmat 6029
+#define SYS_shmctl 6030
+#define SYS_dup 6031
+#define SYS_dup2 6032
+#define SYS_pause 6033
+#define SYS_nanosleep 6034
+#define SYS_getitimer 6035
+#define SYS_setitimer 6036
+#define SYS_alarm 6037
+#define SYS_getpid 6038
+#define SYS_sendfile 6039
+#define SYS_socket 6040
+#define SYS_connect 6041
+#define SYS_accept 6042
+#define SYS_sendto 6043
+#define SYS_recvfrom 6044
+#define SYS_sendmsg 6045
+#define SYS_recvmsg 6046
+#define SYS_shutdown 6047
+#define SYS_bind 6048
+#define SYS_listen 6049
+#define SYS_getsockname 6050
+#define SYS_getpeername 6051
+#define SYS_socketpair 6052
+#define SYS_setsockopt 6053
+#define SYS_getsockopt 6054
+#define SYS_clone 6055
+#define SYS_fork 6056
+#define SYS_execve 6057
+#define SYS_exit 6058
+#define SYS_wait4 6059
+#define SYS_kill 6060
+#define SYS_uname 6061
+#define SYS_semget 6062
+#define SYS_semop 6063
+#define SYS_semctl 6064
+#define SYS_shmdt 6065
+#define SYS_msgget 6066
+#define SYS_msgsnd 6067
+#define SYS_msgrcv 6068
+#define SYS_msgctl 6069
+#define SYS_fcntl 6070
+#define SYS_flock 6071
+#define SYS_fsync 6072
+#define SYS_fdatasync 6073
+#define SYS_truncate 6074
+#define SYS_ftruncate 6075
+#define SYS_getdents 6076
+#define SYS_getcwd 6077
+#define SYS_chdir 6078
+#define SYS_fchdir 6079
+#define SYS_rename 6080
+#define SYS_mkdir 6081
+#define SYS_rmdir 6082
+#define SYS_creat 6083
+#define SYS_link 6084
+#define SYS_unlink 6085
+#define SYS_symlink 6086
+#define SYS_readlink 6087
+#define SYS_chmod 6088
+#define SYS_fchmod 6089
+#define SYS_chown 6090
+#define SYS_fchown 6091
+#define SYS_lchown 6092
+#define SYS_umask 6093
+#define SYS_gettimeofday 6094
+#define SYS_getrlimit 6095
+#define SYS_getrusage 6096
+#define SYS_sysinfo 6097
+#define SYS_times 6098
+#define SYS_ptrace 6099
+#define SYS_getuid 6100
+#define SYS_syslog 6101
+#define SYS_getgid 6102
+#define SYS_setuid 6103
+#define SYS_setgid 6104
+#define SYS_geteuid 6105
+#define SYS_getegid 6106
+#define SYS_setpgid 6107
+#define SYS_getppid 6108
+#define SYS_getpgrp 6109
+#define SYS_setsid 6110
+#define SYS_setreuid 6111
+#define SYS_setregid 6112
+#define SYS_getgroups 6113
+#define SYS_setgroups 6114
+#define SYS_setresuid 6115
+#define SYS_getresuid 6116
+#define SYS_setresgid 6117
+#define SYS_getresgid 6118
+#define SYS_getpgid 6119
+#define SYS_setfsuid 6120
+#define SYS_setfsgid 6121
+#define SYS_getsid 6122
+#define SYS_capget 6123
+#define SYS_capset 6124
+#define SYS_rt_sigpending 6125
+#define SYS_rt_sigtimedwait 6126
+#define SYS_rt_sigqueueinfo 6127
+#define SYS_rt_sigsuspend 6128
+#define SYS_sigaltstack 6129
+#define SYS_utime 6130
+#define SYS_mknod 6131
+#define SYS_personality 6132
+#define SYS_ustat 6133
+#define SYS_statfs 6134
+#define SYS_fstatfs 6135
+#define SYS_sysfs 6136
+#define SYS_getpriority 6137
+#define SYS_setpriority 6138
+#define SYS_sched_setparam 6139
+#define SYS_sched_getparam 6140
+#define SYS_sched_setscheduler 6141
+#define SYS_sched_getscheduler 6142
+#define SYS_sched_get_priority_max 6143
+#define SYS_sched_get_priority_min 6144
+#define SYS_sched_rr_get_interval 6145
+#define SYS_mlock 6146
+#define SYS_munlock 6147
+#define SYS_mlockall 6148
+#define SYS_munlockall 6149
+#define SYS_vhangup 6150
+#define SYS_pivot_root 6151
+#define SYS__sysctl 6152
+#define SYS_prctl 6153
+#define SYS_adjtimex 6154
+#define SYS_setrlimit 6155
+#define SYS_chroot 6156
+#define SYS_sync 6157
+#define SYS_acct 6158
+#define SYS_settimeofday 6159
+#define SYS_mount 6160
+#define SYS_umount2 6161
+#define SYS_swapon 6162
+#define SYS_swapoff 6163
+#define SYS_reboot 6164
+#define SYS_sethostname 6165
+#define SYS_setdomainname 6166
+#define SYS_create_module 6167
+#define SYS_init_module 6168
+#define SYS_delete_module 6169
+#define SYS_get_kernel_syms 6170
+#define SYS_query_module 6171
+#define SYS_quotactl 6172
+#define SYS_nfsservctl 6173
+#define SYS_getpmsg 6174
+#define SYS_putpmsg 6175
+#define SYS_afs_syscall 6176
+#define SYS_reserved177 6177
+#define SYS_gettid 6178
+#define SYS_readahead 6179
+#define SYS_setxattr 6180
+#define SYS_lsetxattr 6181
+#define SYS_fsetxattr 6182
+#define SYS_getxattr 6183
+#define SYS_lgetxattr 6184
+#define SYS_fgetxattr 6185
+#define SYS_listxattr 6186
+#define SYS_llistxattr 6187
+#define SYS_flistxattr 6188
+#define SYS_removexattr 6189
+#define SYS_lremovexattr 6190
+#define SYS_fremovexattr 6191
+#define SYS_tkill 6192
+#define SYS_reserved193 6193
+#define SYS_futex 6194
+#define SYS_sched_setaffinity 6195
+#define SYS_sched_getaffinity 6196
+#define SYS_cacheflush 6197
+#define SYS_cachectl 6198
+#define SYS_sysmips 6199
+#define SYS_io_setup 6200
+#define SYS_io_destroy 6201
+#define SYS_io_getevents 6202
+#define SYS_io_submit 6203
+#define SYS_io_cancel 6204
+#define SYS_exit_group 6205
+#define SYS_lookup_dcookie 6206
+#define SYS_epoll_create 6207
+#define SYS_epoll_ctl 6208
+#define SYS_epoll_wait 6209
+#define SYS_remap_file_pages 6210
+#define SYS_rt_sigreturn 6211
+#define SYS_fcntl64 6212
+#define SYS_set_tid_address 6213
+#define SYS_restart_syscall 6214
+#define SYS_semtimedop 6215
+#define SYS_fadvise64 6216
+#define SYS_statfs64 6217
+#define SYS_fstatfs64 6218
+#define SYS_sendfile64 6219
+#define SYS_timer_create 6220
+#define SYS_timer_settime 6221
+#define SYS_timer_gettime 6222
+#define SYS_timer_getoverrun 6223
+#define SYS_timer_delete 6224
+#define SYS_clock_settime 6225
+#define SYS_clock_gettime 6226
+#define SYS_clock_getres 6227
+#define SYS_clock_nanosleep 6228
+#define SYS_tgkill 6229
+#define SYS_utimes 6230
+#define SYS_mbind 6231
+#define SYS_get_mempolicy 6232
+#define SYS_set_mempolicy 6233
+#define SYS_mq_open 6234
+#define SYS_mq_unlink 6235
+#define SYS_mq_timedsend 6236
+#define SYS_mq_timedreceive 6237
+#define SYS_mq_notify 6238
+#define SYS_mq_getsetattr 6239
+#define SYS_vserver 6240
+#define SYS_waitid 6241
+#define SYS_add_key 6243
+#define SYS_request_key 6244
+#define SYS_keyctl 6245
+#define SYS_set_thread_area 6246
+#define SYS_inotify_init 6247
+#define SYS_inotify_add_watch 6248
+#define SYS_inotify_rm_watch 6249
+#define SYS_migrate_pages 6250
+#define SYS_openat 6251
+#define SYS_mkdirat 6252
+#define SYS_mknodat 6253
+#define SYS_fchownat 6254
+#define SYS_futimesat 6255
+#define SYS_fstatat 6256
+#define SYS_unlinkat 6257
+#define SYS_renameat 6258
+#define SYS_linkat 6259
+#define SYS_symlinkat 6260
+#define SYS_readlinkat 6261
+#define SYS_fchmodat 6262
+#define SYS_faccessat 6263
+#define SYS_pselect6 6264
+#define SYS_ppoll 6265
+#define SYS_unshare 6266
+#define SYS_splice 6267
+#define SYS_sync_file_range 6268
+#define SYS_tee 6269
+#define SYS_vmsplice 6270
+#define SYS_move_pages 6271
+#define SYS_set_robust_list 6272
+#define SYS_get_robust_list 6273
+#define SYS_kexec_load 6274
+#define SYS_getcpu 6275
+#define SYS_epoll_pwait 6276
+#define SYS_ioprio_set 6277
+#define SYS_ioprio_get 6278
+#define SYS_utimensat 6279
+#define SYS_signalfd 6280
+#define SYS_timerfd 6281
+#define SYS_eventfd 6282
+#define SYS_fallocate 6283
+#define SYS_timerfd_create 6284
+#define SYS_timerfd_gettime 6285
+#define SYS_timerfd_settime 6286
+#define SYS_signalfd4 6287
+#define SYS_eventfd2 6288
+#define SYS_epoll_create1 6289
+#define SYS_dup3 6290
+#define SYS_pipe2 6291
+#define SYS_inotify_init1 6292
+#define SYS_preadv 6293
+#define SYS_pwritev 6294
+#define SYS_rt_tgsigqueueinfo 6295
+#define SYS_perf_event_open 6296
+#define SYS_accept4 6297
+#define SYS_recvmmsg 6298
+#define SYS_getdents64 6299
+#define SYS_fanotify_init 6300
+#define SYS_fanotify_mark 6301
+#define SYS_prlimit64 6302
+#define SYS_name_to_handle_at 6303
+#define SYS_open_by_handle_at 6304
+#define SYS_clock_adjtime 6305
+#define SYS_syncfs 6306
+#define SYS_sendmmsg 6307
+#define SYS_setns 6308
+#define SYS_process_vm_readv 6309
+#define SYS_process_vm_writev 6310
+#define SYS_kcmp 6311
+#define SYS_finit_module 6312
+#define SYS_sched_setattr 6313
+#define SYS_sched_getattr 6314
+#define SYS_renameat2 6315
+#define SYS_seccomp 6316
+#define SYS_getrandom 6317
+#define SYS_memfd_create 6318
+#define SYS_bpf 6319
+#define SYS_execveat 6320
+#define SYS_userfaultfd 6321
+#define SYS_membarrier 6322
+#define SYS_mlock2 6323
+#define SYS_copy_file_range 6324
diff --git a/arch/mipsn32/bits/termios.h b/arch/mipsn32/bits/termios.h
new file mode 100644
index 0000000..3a7d5a1
--- /dev/null
+++ b/arch/mipsn32/bits/termios.h
@@ -0,0 +1,166 @@
+struct termios {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+};
+
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VMIN 4
+#define VTIME 5
+#define VEOL2 6
+#define VSWTC 7
+#define VSWTCH 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOF 16
+#define VEOL 17
+
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
+
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#define NLDLY 0000400
+#define NL0 0000000
+#define NL1 0000400
+#define CRDLY 0003000
+#define CR0 0000000
+#define CR1 0001000
+#define CR2 0002000
+#define CR3 0003000
+#define TABDLY 0014000
+#define TAB0 0000000
+#define TAB1 0004000
+#define TAB2 0010000
+#define TAB3 0014000
+#define BSDLY 0020000
+#define BS0 0000000
+#define BS1 0020000
+#define FFDLY 0100000
+#define FF0 0000000
+#define FF1 0100000
+
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+
+#define B0 0000000
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#define EXTA 0000016
+#define EXTB 0000017
+
+#define BOTHER 0010000
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+
+#define CBAUD 0010017
+
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+
+#define ISIG 0000001
+#define ICANON 0000002
+#define XCASE 0000004
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define IEXTEN 0000400
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0020000
+#define PENDIN 0040000
+#define TOSTOP 0100000
+#define ITOSTOP 0100000
+
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define CBAUDEX 0010000
+#define CIBAUD 002003600000
+#define IBSHIFT 16
+#define CMSPAR 010000000000
+#define CRTSCTS 020000000000
+#define EXTPROC 0200000
+#define XTABS 0014000
+#define TIOCSER_TEMT 1
+#endif
diff --git a/arch/mipsn32/bits/user.h b/arch/mipsn32/bits/user.h
new file mode 100644
index 0000000..60fa1fd
--- /dev/null
+++ b/arch/mipsn32/bits/user.h
@@ -0,0 +1,15 @@
+struct user {
+ unsigned long regs[102];
+ unsigned long u_tsize, u_dsize, u_ssize;
+ unsigned long long start_code, start_data, start_stack;
+ long long signal;
+ unsigned long long *u_ar0;
+ unsigned long long magic;
+ char u_comm[32];
+};
+
+#define ELF_NGREG 45
+#define ELF_NFPREG 33
+
+typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
+typedef double elf_fpreg_t, elf_fpregset_t[ELF_NFPREG];
diff --git a/arch/mipsn32/crt_arch.h b/arch/mipsn32/crt_arch.h
new file mode 100644
index 0000000..eb5928c
--- /dev/null
+++ b/arch/mipsn32/crt_arch.h
@@ -0,0 +1,32 @@
+__asm__(
+".set push\n"
+".set noreorder\n"
+".text \n"
+".global _" START "\n"
+".global " START "\n"
+".global " START "_data\n"
+".type _" START ", @function\n"
+".type " START ", @function\n"
+".type " START "_data, @function\n"
+"_" START ":\n"
+"" START ":\n"
+" bal 1f \n"
+" move $fp, $0 \n"
+"" START "_data: \n"
+" .gpword " START "_data \n"
+" .gpword " START "_c \n"
+".weak _DYNAMIC \n"
+".hidden _DYNAMIC \n"
+" .gpword _DYNAMIC \n"
+"1: lw $gp, 0($ra) \n"
+" subu $gp, $ra, $gp \n"
+" move $4, $sp \n"
+" lw $5, 8($ra) \n"
+" addu $5, $5, $gp \n"
+" lw $25, 4($ra) \n"
+" addu $25, $25, $gp \n"
+" and $sp, $sp, -8 \n"
+" jalr $25 \n"
+" subu $sp, $sp, 16 \n"
+".set pop \n"
+);
diff --git a/arch/mipsn32/ksigaction.h b/arch/mipsn32/ksigaction.h
new file mode 100644
index 0000000..9969e3b
--- /dev/null
+++ b/arch/mipsn32/ksigaction.h
@@ -0,0 +1,8 @@
+struct k_sigaction {
+ unsigned flags;
+ void (*handler)(int);
+ unsigned long mask[4];
+ void (*restorer)();
+};
+
+void __restore(), __restore_rt();
diff --git a/arch/mipsn32/pthread_arch.h b/arch/mipsn32/pthread_arch.h
new file mode 100644
index 0000000..e581265
--- /dev/null
+++ b/arch/mipsn32/pthread_arch.h
@@ -0,0 +1,18 @@
+static inline struct pthread *__pthread_self()
+{
+#if __mips_isa_rev < 2
+ register char *tp __asm__("$3");
+ __asm__ __volatile__ (".word 0x7c03e83b" : "=r" (tp) );
+#else
+ char *tp;
+ __asm__ __volatile__ ("rdhwr %0, $29" : "=r" (tp) );
+#endif
+ return (pthread_t)(tp - 0x7000 - sizeof(struct pthread));
+}
+
+#define TLS_ABOVE_TP
+#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
+
+#define DTP_OFFSET 0x8000
+
+#define MC_PC pc
diff --git a/arch/mipsn32/reloc.h b/arch/mipsn32/reloc.h
new file mode 100644
index 0000000..728aaab
--- /dev/null
+++ b/arch/mipsn32/reloc.h
@@ -0,0 +1,52 @@
+#include <endian.h>
+
+#if __mips_isa_rev >= 6
+#define ISA_SUFFIX "r6"
+#else
+#define ISA_SUFFIX ""
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define ENDIAN_SUFFIX "el"
+#else
+#define ENDIAN_SUFFIX ""
+#endif
+
+#ifdef __mips_soft_float
+#define FP_SUFFIX "-sf"
+#else
+#define FP_SUFFIX ""
+#endif
+
+#define LDSO_ARCH "mipsn32" ISA_SUFFIX ENDIAN_SUFFIX FP_SUFFIX
+
+#define TPOFF_K (-0x7000)
+
+#define REL_SYM_OR_REL R_MIPS_REL32
+#define REL_PLT R_MIPS_JUMP_SLOT
+#define REL_COPY R_MIPS_COPY
+#define REL_DTPMOD R_MIPS_TLS_DTPMOD32
+#define REL_DTPOFF R_MIPS_TLS_DTPREL32
+#define REL_TPOFF R_MIPS_TLS_TPREL32
+
+#define NEED_MIPS_GOT_RELOCS 1
+#define DT_DEBUG_INDIRECT DT_MIPS_RLD_MAP
+#define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))
+
+#define CRTJMP(pc,sp) __asm__ __volatile__( \
+ "move $sp,%1 ; jr %0" : : "r"(pc), "r"(sp) : "memory" )
+
+#define GETFUNCSYM(fp, sym, got) __asm__ ( \
+ ".hidden " #sym "\n" \
+ ".set push \n" \
+ ".set noreorder \n" \
+ " bal 1f \n" \
+ " nop \n" \
+ " .gpword . \n" \
+ " .gpword " #sym " \n" \
+ "1: lw %0, ($ra) \n" \
+ " subu %0, $ra, %0 \n" \
+ " lw $ra, 4($ra) \n" \
+ " addu %0, %0, $ra \n" \
+ ".set pop \n" \
+ : "=r"(*(fp)) : : "memory", "ra" )
diff --git a/arch/mipsn32/syscall_arch.h b/arch/mipsn32/syscall_arch.h
new file mode 100644
index 0000000..58d2c8b
--- /dev/null
+++ b/arch/mipsn32/syscall_arch.h
@@ -0,0 +1,165 @@
+#define __SYSCALL_LL_E(x) (x)
+#define __SYSCALL_LL_O(x) (x)
+
+__attribute__((visibility("hidden")))
+long (__syscall)(long, ...);
+
+#define SYSCALL_RLIM_INFINITY (-1UL/2)
+
+#if _MIPSEL || __MIPSEL || __MIPSEL__
+#define __stat_fix(st) ((st),(void)0)
+#else
+#include <sys/stat.h>
+static inline void __stat_fix(long p)
+{
+ struct stat *st = (struct stat *)p;
+ st->st_dev >>= 32;
+ st->st_rdev >>= 32;
+}
+#endif
+
+#ifndef __clang__
+
+static inline long __syscall0(long n)
+{
+ register long r7 __asm__("$7");
+ register long r2 __asm__("$2");
+ __asm__ __volatile__ (
+ "addu $2,$0,%2 ; syscall"
+ : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7)
+ : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ return r7 ? -r2 : r2;
+}
+
+static inline long __syscall1(long n, long a)
+{
+ register long r4 __asm__("$4") = a;
+ register long r7 __asm__("$7");
+ register long r2 __asm__("$2");
+ __asm__ __volatile__ (
+ "addu $2,$0,%2 ; syscall"
+ : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
+ "r"(r4)
+ : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ return r7 ? -r2 : r2;
+}
+
+static inline long __syscall2(long n, long a, long b)
+{
+ register long r4 __asm__("$4") = a;
+ register long r5 __asm__("$5") = b;
+ register long r7 __asm__("$7");
+ register long r2 __asm__("$2");
+ __asm__ __volatile__ (
+ "addu $2,$0,%2 ; syscall"
+ : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
+ "r"(r4), "r"(r5)
+ : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ if (r7) return -r2;
+ long ret = r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ return ret;
+}
+
+static inline long __syscall3(long n, long a, long b, long c)
+{
+ register long r4 __asm__("$4") = a;
+ register long r5 __asm__("$5") = b;
+ register long r6 __asm__("$6") = c;
+ register long r7 __asm__("$7");
+ register long r2 __asm__("$2");
+ __asm__ __volatile__ (
+ "addu $2,$0,%2 ; syscall"
+ : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
+ "r"(r4), "r"(r5), "r"(r6)
+ : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ if (r7) return -r2;
+ long ret = r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ return ret;
+}
+
+static inline long __syscall4(long n, long a, long b, long c, long d)
+{
+ register long r4 __asm__("$4") = a;
+ register long r5 __asm__("$5") = b;
+ register long r6 __asm__("$6") = c;
+ register long r7 __asm__("$7") = d;
+ register long r2 __asm__("$2");
+ __asm__ __volatile__ (
+ "addu $2,$0,%2 ; syscall"
+ : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7),
+ "r"(r4), "r"(r5), "r"(r6)
+ : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory");
+ if (r7) return -r2;
+ long ret = r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ if (n == SYS_fstatat) __stat_fix(c);
+ return ret;
+}
+
+#else
+
+static inline long __syscall0(long n)
+{
+ return (__syscall)(n);
+}
+
+static inline long __syscall1(long n, long a)
+{
+ return (__syscall)(n, a);
+}
+
+static inline long __syscall2(long n, long a, long b)
+{
+ long r2 = (__syscall)(n, a, b);
+ if (r2 > -4096UL) return r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ return r2;
+}
+
+static inline long __syscall3(long n, long a, long b, long c)
+{
+ long r2 = (__syscall)(n, a, b, c);
+ if (r2 > -4096UL) return r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ return r2;
+}
+
+static inline long __syscall4(long n, long a, long b, long c, long d)
+{
+ long r2 = (__syscall)(n, a, b, c, d);
+ if (r2 > -4096UL) return r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ if (n == SYS_fstatat) __stat_fix(c);
+ return r2;
+}
+
+#endif
+
+static inline long __syscall5(long n, long a, long b, long c, long d, long e)
+{
+ long r2 = (__syscall)(n, a, b, c, d, e);
+ if (r2 > -4096UL) return r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ if (n == SYS_fstatat) __stat_fix(c);
+ return r2;
+}
+
+static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
+{
+ long r2 = (__syscall)(n, a, b, c, d, e, f);
+ if (r2 > -4096UL) return r2;
+ if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
+ if (n == SYS_fstatat) __stat_fix(c);
+ return r2;
+}
+
+#define VDSO_USEFUL
+#define VDSO_CGT_SYM "__vdso_clock_gettime"
+#define VDSO_CGT_VER "LINUX_2.6"
diff --git a/configure b/configure
index 969671d..53241ab 100755
--- a/configure
+++ b/configure
@@ -618,6 +618,7 @@
fi
if test "$ARCH" = "mips64" ; then
+trycppif "_MIPS_SIM != _ABI64" "$t" && ARCH=mipsn32
trycppif "__mips_isa_rev >= 6" "$t" && SUBARCH=${SUBARCH}r6
trycppif "_MIPSEL || __MIPSEL || __MIPSEL__" "$t" && SUBARCH=${SUBARCH}el
trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf
diff --git a/crt/mipsn32/crti.s b/crt/mipsn32/crti.s
new file mode 100644
index 0000000..14fa28d
--- /dev/null
+++ b/crt/mipsn32/crti.s
@@ -0,0 +1,18 @@
+.set noreorder
+.section .init
+.global _init
+.type _init,@function
+.align 2
+_init:
+ subu $sp, $sp, 32
+ sd $gp, 16($sp)
+ sd $ra, 24($sp)
+
+.section .fini
+.global _fini
+.type _fini,@function
+.align 2
+_fini:
+ subu $sp, $sp, 32
+ sd $gp, 16($sp)
+ sd $ra, 24($sp)
diff --git a/crt/mipsn32/crtn.s b/crt/mipsn32/crtn.s
new file mode 100644
index 0000000..dccd7e8
--- /dev/null
+++ b/crt/mipsn32/crtn.s
@@ -0,0 +1,12 @@
+.set noreorder
+.section .init
+ ld $gp, 16($sp)
+ ld $ra, 24($sp)
+ j $ra
+ addu $sp, $sp, 32
+
+.section .fini
+ ld $gp, 16($sp)
+ ld $ra, 24($sp)
+ j $ra
+ addu $sp, $sp, 32
diff --git a/src/fenv/mipsn32/fenv-sf.c b/src/fenv/mipsn32/fenv-sf.c
new file mode 100644
index 0000000..4aa3dbf
--- /dev/null
+++ b/src/fenv/mipsn32/fenv-sf.c
@@ -0,0 +1,3 @@
+#ifdef __mips_soft_float
+#include "../fenv.c"
+#endif
diff --git a/src/fenv/mipsn32/fenv.S b/src/fenv/mipsn32/fenv.S
new file mode 100644
index 0000000..cce6436
--- /dev/null
+++ b/src/fenv/mipsn32/fenv.S
@@ -0,0 +1,70 @@
+#ifndef __mips_soft_float
+
+.set noreorder
+.global feclearexcept
+.type feclearexcept,@function
+feclearexcept:
+ and $4, $4, 0x7c
+ cfc1 $5, $31
+ or $5, $5, $4
+ xor $5, $5, $4
+ ctc1 $5, $31
+ jr $ra
+ li $2, 0
+
+.global feraiseexcept
+.type feraiseexcept,@function
+feraiseexcept:
+ and $4, $4, 0x7c
+ cfc1 $5, $31
+ or $5, $5, $4
+ ctc1 $5, $31
+ jr $ra
+ li $2, 0
+
+.global fetestexcept
+.type fetestexcept,@function
+fetestexcept:
+ and $4, $4, 0x7c
+ cfc1 $2, $31
+ jr $ra
+ and $2, $2, $4
+
+.global fegetround
+.type fegetround,@function
+fegetround:
+ cfc1 $2, $31
+ jr $ra
+ andi $2, $2, 3
+
+.global __fesetround
+.type __fesetround,@function
+__fesetround:
+ cfc1 $5, $31
+ li $6, -4
+ and $5, $5, $6
+ or $5, $5, $4
+ ctc1 $5, $31
+ jr $ra
+ li $2, 0
+
+.global fegetenv
+.type fegetenv,@function
+fegetenv:
+ cfc1 $5, $31
+ sw $5, 0($4)
+ jr $ra
+ li $2, 0
+
+.global fesetenv
+.type fesetenv,@function
+fesetenv:
+ addiu $5, $4, 1
+ beq $5, $0, 1f
+ nop
+ lw $5, 0($4)
+1: ctc1 $5, $31
+ jr $ra
+ li $2, 0
+
+#endif
diff --git a/src/internal/mipsn32/syscall.s b/src/internal/mipsn32/syscall.s
new file mode 100644
index 0000000..510a6fa
--- /dev/null
+++ b/src/internal/mipsn32/syscall.s
@@ -0,0 +1,19 @@
+.set noreorder
+.global __syscall
+.hidden __syscall
+.type __syscall,@function
+__syscall:
+ move $2, $4
+ move $4, $5
+ move $5, $6
+ move $6, $7
+ move $7, $8
+ move $8, $9
+ move $9, $10
+ move $10, $11
+ syscall
+ beq $7, $0, 1f
+ nop
+ subu $2, $0, $2
+1: jr $ra
+ nop
diff --git a/src/ldso/mipsn32/dlsym.s b/src/ldso/mipsn32/dlsym.s
new file mode 100644
index 0000000..1c82da3
--- /dev/null
+++ b/src/ldso/mipsn32/dlsym.s
@@ -0,0 +1,17 @@
+.set noreorder
+.global dlsym
+.hidden __dlsym
+.type dlsym,@function
+dlsym:
+ lui $3, %hi(%neg(%gp_rel(dlsym)))
+ addiu $3, $3, %lo(%neg(%gp_rel(dlsym)))
+ addu $3, $3, $25
+ move $6, $ra
+ lw $25, %got_disp(__dlsym)($3)
+ addiu $sp, $sp, -32
+ sd $ra, 16($sp)
+ jalr $25
+ nop
+ ld $ra, 16($sp)
+ jr $ra
+ addiu $sp, $sp, 32
diff --git a/src/setjmp/mipsn32/longjmp.S b/src/setjmp/mipsn32/longjmp.S
new file mode 100644
index 0000000..30c3ee0
--- /dev/null
+++ b/src/setjmp/mipsn32/longjmp.S
@@ -0,0 +1,36 @@
+.set noreorder
+.global _longjmp
+.global longjmp
+.type _longjmp,@function
+.type longjmp,@function
+_longjmp:
+longjmp:
+ move $2, $5
+ bne $2, $0, 1f
+ nop
+ addu $2, $2, 1
+1:
+#ifndef __mips_soft_float
+ ldc1 $24, 96($4)
+ ldc1 $25, 104($4)
+ ldc1 $26, 112($4)
+ ldc1 $27, 120($4)
+ ldc1 $28, 128($4)
+ ldc1 $29, 136($4)
+ ldc1 $30, 144($4)
+ ldc1 $31, 152($4)
+#endif
+ ld $ra, 0($4)
+ ld $sp, 8($4)
+ ld $gp, 16($4)
+ ld $16, 24($4)
+ ld $17, 32($4)
+ ld $18, 40($4)
+ ld $19, 48($4)
+ ld $20, 56($4)
+ ld $21, 64($4)
+ ld $22, 72($4)
+ ld $23, 80($4)
+ ld $30, 88($4)
+ jr $ra
+ nop
diff --git a/src/setjmp/mipsn32/setjmp.S b/src/setjmp/mipsn32/setjmp.S
new file mode 100644
index 0000000..b9646c2
--- /dev/null
+++ b/src/setjmp/mipsn32/setjmp.S
@@ -0,0 +1,34 @@
+.set noreorder
+.global __setjmp
+.global _setjmp
+.global setjmp
+.type __setjmp,@function
+.type _setjmp,@function
+.type setjmp,@function
+__setjmp:
+_setjmp:
+setjmp:
+ sd $ra, 0($4)
+ sd $sp, 8($4)
+ sd $gp, 16($4)
+ sd $16, 24($4)
+ sd $17, 32($4)
+ sd $18, 40($4)
+ sd $19, 48($4)
+ sd $20, 56($4)
+ sd $21, 64($4)
+ sd $22, 72($4)
+ sd $23, 80($4)
+ sd $30, 88($4)
+#ifndef __mips_soft_float
+ sdc1 $24, 96($4)
+ sdc1 $25, 104($4)
+ sdc1 $26, 112($4)
+ sdc1 $27, 120($4)
+ sdc1 $28, 128($4)
+ sdc1 $29, 136($4)
+ sdc1 $30, 144($4)
+ sdc1 $31, 152($4)
+#endif
+ jr $ra
+ li $2, 0
diff --git a/src/signal/mipsn32/restore.s b/src/signal/mipsn32/restore.s
new file mode 100644
index 0000000..0d1c1c5
--- /dev/null
+++ b/src/signal/mipsn32/restore.s
@@ -0,0 +1,9 @@
+.set noreorder
+.global __restore_rt
+.global __restore
+.type __restore_rt,@function
+.type __restore,@function
+__restore_rt:
+__restore:
+ li $2,6211
+ syscall
diff --git a/src/signal/mipsn32/sigsetjmp.s b/src/signal/mipsn32/sigsetjmp.s
new file mode 100644
index 0000000..c0c6961
--- /dev/null
+++ b/src/signal/mipsn32/sigsetjmp.s
@@ -0,0 +1,38 @@
+.set noreorder
+.global sigsetjmp
+.global __sigsetjmp
+.type sigsetjmp,@function
+.type __sigsetjmp,@function
+sigsetjmp:
+__sigsetjmp:
+ lui $3, %hi(%neg(%gp_rel(sigsetjmp)))
+ addiu $3, $3, %lo(%neg(%gp_rel(sigsetjmp)))
+
+ # comparing save mask with 0, if equals to 0 then
+ # sigsetjmp is equal to setjmp.
+ beq $5, $0, 1f
+ addu $3, $3, $25
+ sd $ra, 160($4)
+ sd $16, 168($4)
+
+ # save base of got so that we can use it later
+ # once we return from 'longjmp'
+ sd $3, 176($4)
+ lw $25, %got_disp(setjmp)($3)
+ jalr $25
+ move $16, $4
+
+ move $5, $2 # Return from 'setjmp' or 'longjmp'
+ move $4, $16 # Restore the pointer-to-sigjmp_buf
+ ld $ra, 160($4) # Restore ra of sigsetjmp
+ ld $16, 168($4) # Restore $16 of sigsetjmp
+ ld $3, 176($4) # Restore base of got
+
+.hidden __sigsetjmp_tail
+ lw $25, %got_disp(__sigsetjmp_tail)($3)
+ jr $25
+ nop
+1:
+ lw $25, %got_disp(setjmp)($3)
+ jr $25
+ nop
diff --git a/src/thread/mipsn32/__unmapself.s b/src/thread/mipsn32/__unmapself.s
new file mode 100644
index 0000000..4b032e5
--- /dev/null
+++ b/src/thread/mipsn32/__unmapself.s
@@ -0,0 +1,9 @@
+.set noreorder
+.global __unmapself
+.type __unmapself,@function
+__unmapself:
+ li $2, 6011
+ syscall
+ li $4, 0
+ li $2, 6058
+ syscall
diff --git a/src/thread/mipsn32/clone.s b/src/thread/mipsn32/clone.s
new file mode 100644
index 0000000..5103585
--- /dev/null
+++ b/src/thread/mipsn32/clone.s
@@ -0,0 +1,30 @@
+.set noreorder
+.global __clone
+.type __clone,@function
+__clone:
+ # Save function pointer and argument pointer on new thread stack
+ and $5, $5, -16 # aligning stack to double word
+ subu $5, $5, 16
+ sw $4, 0($5) # save function pointer
+ sw $7, 4($5) # save argument pointer
+
+ # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
+ # sys_clone(u64 flags, u64 ustack_base, u64 parent_tidptr, u64 child_tidptr, u64 tls)
+ move $4, $6
+ move $6, $8
+ move $7, $9
+ move $8, $10
+ li $2, 6055
+ syscall
+ beq $7, $0, 1f
+ nop
+ jr $ra
+ subu $2, $0, $2
+1: beq $2, $0, 1f
+ nop
+ jr $ra
+ nop
+1: lw $25, 0($sp) # function pointer
+ lw $4, 4($sp) # argument pointer
+ jr $25 # call the user's function
+ nop
diff --git a/src/thread/mipsn32/syscall_cp.s b/src/thread/mipsn32/syscall_cp.s
new file mode 100644
index 0000000..e85615b
--- /dev/null
+++ b/src/thread/mipsn32/syscall_cp.s
@@ -0,0 +1,51 @@
+.set noreorder
+.global __cp_begin
+.hidden __cp_begin
+.type __cp_begin,@function
+.global __cp_end
+.hidden __cp_end
+.type __cp_end,@function
+.global __cp_cancel
+.hidden __cp_cancel
+.type __cp_cancel,@function
+.global __cp_cancel_data
+.hidden __cp_cancel_data
+.type __cp_cancel_data,@function
+.hidden __cancel
+.global __syscall_cp_asm
+.hidden __syscall_cp_asm
+.type __syscall_cp_asm,@function
+__syscall_cp_asm:
+__cp_begin:
+ lw $4, 0($4)
+ bne $4, $0, __cp_cancel
+ move $2, $5
+ move $4, $6
+ move $5, $7
+ move $6, $8
+ move $7, $9
+ move $8, $10
+ move $9, $11
+ lw $10, 0($sp)
+ syscall
+__cp_end:
+ beq $7, $0, 1f
+ nop
+ subu $2, $0, $2
+1: jr $ra
+ nop
+
+ # if cancellation flag is 1 then call __cancel
+__cp_cancel:
+ move $2, $ra
+ bal 1f
+ nop
+__cp_cancel_data:
+ .gpword __cp_cancel_data
+ .gpword __cancel
+1: lw $3, 0($ra)
+ subu $3, $ra, $3
+ lw $25, 4($ra)
+ addu $25, $25, $3
+ jr $25
+ move $ra, $2
diff --git a/src/unistd/mipsn32/pipe.s b/src/unistd/mipsn32/pipe.s
new file mode 100644
index 0000000..80f882e
--- /dev/null
+++ b/src/unistd/mipsn32/pipe.s
@@ -0,0 +1,19 @@
+.set noreorder
+.global pipe
+.type pipe,@function
+pipe:
+ lui $3, %hi(%neg(%gp_rel(pipe)))
+ addiu $3, $3, %lo(%neg(%gp_rel(pipe)))
+ addu $3, $3, $25
+ li $2, 6021
+ syscall
+ beq $7, $0, 1f
+ nop
+ lw $25, %got_disp(__syscall_ret)($3)
+ jr $25
+ subu $4, $0, $2
+1: sw $2, 0($4)
+ sw $3, 4($4)
+ move $2, $0
+ jr $ra
+ nop