Ignore BC size budget on very cheap regions
[hiphop-php.git] / hphp / util / embedded-data.h
bloba565d9181d8614d148a40793a94153178d48f840
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #pragma once
19 #ifdef __cplusplus
21 #include <cstdint>
22 #include <string>
24 namespace HPHP {
26 ///////////////////////////////////////////////////////////////////////////////
28 struct embedded_data {
29 std::string m_filename;
30 uint64_t m_start;
31 uint64_t m_len;
32 #ifdef _MSC_VER
33 void* m_handle;
34 #endif
37 bool get_embedded_data(const char* section, embedded_data* desc,
38 const std::string& filename = "");
40 std::string read_embedded_data(const embedded_data& desc);
43 * dlopen() the embedded shared object given by `desc'.
45 * Unfortunately, there's no way to do the equivalent of dlopen() on data
46 * within another file, or even in memory. This means we have to copy the
47 * section into a temporary file and then dlopen() that.
49 * If trust is true, than any existing file with the same name as the first
50 * extract path will be used without extracting the data. Otherwise if the file
51 * exists, its contents will be verified before using. If the file does not
52 * exist, it will be created and the embedded data copied into it. If this fails
53 * for any reason, the fallback path is used, if provided.
55 * Returns the result of dlopen() on success, else nullptr. Also logs the
56 * failure condition with Logger on failure.
58 void* dlopen_embedded_data(const embedded_data& desc,
59 std::string extractPath,
60 std::string fallbackPath,
61 const std::string& buildId,
62 bool trust);
65 * Clean up any fallback files that we created at process shutdown time.
67 void embedded_data_cleanup();
70 ///////////////////////////////////////////////////////////////////////////////
74 #else //__cplusplus
77 * Read data from the named section and place it into the given buffer (of size
78 * len) Returns the number of bytes (not null-terminated) read or -1 if
79 * unsuccessful
81 ssize_t hphp_read_embedded_data(const char* section, char* buf, size_t len);
83 #endif //__cplusplus