CS350 COS
COS
Loading...
Searching...
No Matches
exit.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <syscall.h>
Include dependency graph for exit.c:

Go to the source code of this file.

Data Structures

struct  atexit_cb
 

Functions

int atexit (void(*function)(void))
 
void exit (int status)
 

Variables

static uint64_t _atexit_count = 0
 
static struct atexit_cb _atexits [32]
 
static struct atexit_cb_atexit_last = NULL
 

Function Documentation

◆ atexit()

int atexit ( void(*)(void)  function)

Definition at line 17 of file exit.c.

18{
19 if (_atexit_count < 32) {
20 struct atexit_cb *prev = _atexit_last;
21
22 _atexits[_atexit_count].cb = function;
24
27 } else {
28 // XXX: Support malloc
29 return -1;
30 }
31
32 return 0;
33}
static uint64_t _atexit_count
Definition: exit.c:12
static struct atexit_cb _atexits[32]
Definition: exit.c:13
static struct atexit_cb * _atexit_last
Definition: exit.c:14
Definition: exit.c:7
void(* cb)(void)
Definition: exit.c:9
struct atexit_cb * next
Definition: exit.c:8
Here is the caller graph for this function:

◆ exit()

void exit ( int  status)

Definition at line 36 of file exit.c.

37{
38 while (_atexit_last != NULL) {
39 (_atexit_last->cb)();
41 }
42
43 OSExit(status & 0x00ff);
44
45 __builtin_unreachable();
46}
void OSExit(int status)
Definition: syscall.c:17
#define NULL
Definition: stddef.h:6
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _atexit_count

uint64_t _atexit_count = 0
static

Definition at line 12 of file exit.c.

◆ _atexit_last

struct atexit_cb* _atexit_last = NULL
static

Definition at line 14 of file exit.c.

◆ _atexits

struct atexit_cb _atexits[32]
static

Definition at line 13 of file exit.c.