From 02c661b88384a4a0cd5dd2b32123968bd992873f Mon Sep 17 00:00:00 2001
From: Elliott Hughes <enh@google.com>
Date: Wed, 29 Jan 2014 18:37:15 -0800
Subject: [PATCH] Add mips <sys/ucontext.h>.

Change-Id: I2821f523f0c3bb4400b2ad5d36e21e5a3d6d777c
---
 libc/include/sys/ucontext.h | 47 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/libc/include/sys/ucontext.h b/libc/include/sys/ucontext.h
index e7fbcd65f..c65e2b615 100644
--- a/libc/include/sys/ucontext.h
+++ b/libc/include/sys/ucontext.h
@@ -143,7 +143,52 @@ typedef struct ucontext {
 
 #elif defined(__mips__)
 
-#error TODO
+/* glibc doesn't have names for MIPS registers. */
+
+#define NGREG 32
+#define NFPREG 32
+
+typedef unsigned long long greg_t;
+typedef greg_t gregset_t[NGREG];
+
+typedef struct fpregset {
+  union {
+    double fp_dregs[NFPREG];
+    struct {
+      float _fp_fregs;
+      unsigned _fp_pad;
+    } fp_fregs[NFPREG];
+  } fp_r;
+} fpregset_t;
+
+typedef struct {
+  unsigned regmask;
+  unsigned status;
+  greg_t pc;
+  gregset_t gregs;
+  fpregset_t fpregs;
+  unsigned fp_owned;
+  unsigned fpc_csr;
+  unsigned fpc_eir;
+  unsigned used_math;
+  unsigned dsp;
+  greg_t mdhi;
+  greg_t mdlo;
+  unsigned long hi1;
+  unsigned long lo1;
+  unsigned long hi2;
+  unsigned long lo2;
+  unsigned long hi3;
+  unsigned long lo3;
+} mcontext_t;
+
+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;
 
 #elif defined(__mips64__)