PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/rt/arch/i386/context.h

http://github.com/jruderman/rust
C Header | 44 lines | 26 code | 13 blank | 5 comment | 0 complexity | 3882e8adbbfbbb51adb6bacd42bbe9fd MD5 | raw file
 1// -*- mode: c++ -*-
 2
 3#ifndef CONTEXT_H
 4#define CONTEXT_H
 5
 6#include <cstdlib>
 7#include <inttypes.h>
 8#include <stdint.h>
 9
10#include "vg/memcheck.h"
11
12template<typename T>
13T align_down(T sp)
14{
15    // There is no platform we care about that needs more than a
16    // 16-byte alignment.
17    return (T)((uint32_t)sp & ~(16 - 1));
18}
19
20struct registers_t {
21  // general purpose registers
22  uint32_t eax, ebx, ecx, edx, ebp, esi, edi, esp;
23
24  // segment registers
25  uint16_t cs, ds, ss, es, fs, gs;
26
27  uint32_t eflags;
28
29  uint32_t eip;
30} __attribute__((aligned(16)));
31
32class context {
33public:
34  registers_t regs;
35
36  context();
37
38  context *next;
39
40  void swap(context &out);
41  void call(void *f, void *arg, void *sp);
42};
43
44#endif