blob: 0e026e10b1426a61b6d12c1703103607d460c70a [file] [log] [blame]
Misha Brukman2e1fbdd2003-09-29 22:37:00 +00001/*===- OSInterface.h - Interface to query OS for functionality ---*- C -*--===*\
Misha Brukman3b87f212004-08-04 21:19:49 +00002 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file was developed by the LLVM research group and is distributed under
6 * the University of Illinois Open Source License. See LICENSE.TXT for details.
7 *
8 *===----------------------------------------------------------------------===
9 *
10 *
11 * This file defines the prototype interface that we will expect operating
12 * systems to implement if they wish to support offline cachine.
13 *
Misha Brukman2e1fbdd2003-09-29 22:37:00 +000014\*===----------------------------------------------------------------------===*/
15
16#ifndef OS_INTERFACE_H
17#define OS_INTERFACE_H
18
Reid Spencer551ccae2004-09-01 22:55:40 +000019#include "llvm/Config/sys/types.h"
Misha Brukman2e1fbdd2003-09-29 22:37:00 +000020
21struct stat;
22
23/*
24 * llvmStat - equivalent to stat(3), except the key may not necessarily
25 * correspond to a file by that name, implementation is up to the OS.
26 * Values returned in buf are similar as they are in Unix.
27 */
28void llvmStat(const char *key, struct stat *buf);
29
30/*
31 * llvmWriteFile - implements a 'save' of a file in the OS. 'key' may not
32 * necessarily map to a file of the same name.
33 * Returns:
34 * 0 - success
35 * non-zero - error
36 */
37int llvmWriteFile(const char *key, const void *data, size_t len);
38
39/*
40 * llvmLoadFile - tells the OS to load data corresponding to a particular key
41 * somewhere into memory.
42 * Returns:
43 * 0 - failure
44 * non-zero - address of loaded file
45 *
46 * Value of size is the length of data loaded into memory.
47 */
48void* llvmReadFile(const char *key, size_t *size);
49
50/*
51 * llvmExecve - execute a file from cache. This is a temporary proof-of-concept
52 * because we do not relocate what we can read from disk.
53 */
54int llvmExecve(const char *filename, char *const argv[], char *const envp[]);
55
56#endif