aboutsummaryrefslogtreecommitdiff
path: root/src/blocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/blocks')
-rw-r--r--src/blocks/CMakeLists.txt37
-rw-r--r--src/blocks/blockexports.c48
-rw-r--r--src/blocks/blocks.datbin0 -> 19200004 bytes
-rw-r--r--src/blocks/blocks.h16
4 files changed, 101 insertions, 0 deletions
diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt
new file mode 100644
index 000000000..0ad885388
--- /dev/null
+++ b/src/blocks/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright (c) 2014-2015, The Monero Project
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other
+# materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be
+# used to endorse or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+if(APPLE)
+ add_library(blocks STATIC blockexports.c)
+ set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C)
+else()
+ add_custom_command(OUTPUT blocks.o COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ld -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/blocks.o blocks.dat)
+ add_library(blocks STATIC blocks.o blockexports.c)
+ set_target_properties(blocks PROPERTIES LINKER_LANGUAGE C)
+endif()
+
diff --git a/src/blocks/blockexports.c b/src/blocks/blockexports.c
new file mode 100644
index 000000000..cea72b299
--- /dev/null
+++ b/src/blocks/blockexports.c
@@ -0,0 +1,48 @@
+#include <stddef.h>
+
+#if defined(__APPLE__)
+#include <mach-o/getsect.h>
+
+#if !defined(__LP64__)
+extern const struct mach_header _mh_execute_header;
+#else
+extern const struct mach_header_64 _mh_execute_header;
+#endif
+
+const unsigned char *get_blocks_dat_start()
+{
+ size_t size;
+ return getsectiondata(&_mh_execute_header, "__DATA", "__blocks_dat", &size);
+}
+
+size_t get_blocks_dat_size()
+{
+ size_t size;
+ getsectiondata(&_mh_execute_header, "__DATA", "__blocks_dat", &size);
+ return size;
+}
+
+#else
+
+#if defined(_WIN32) && !defined(_WIN64)
+#define _binary_blocks_start binary_blocks_dat_start
+#define _binary_blocks_end binary_blocks_dat_end
+#else
+#define _binary_blocks_start _binary_blocks_dat_start
+#define _binary_blocks_end _binary_blocks_dat_end
+#endif
+
+extern const unsigned char _binary_blocks_start[];
+extern const unsigned char _binary_blocks_end[];
+
+const unsigned char *get_blocks_dat_start(void)
+{
+ return _binary_blocks_start;
+}
+
+size_t get_blocks_dat_size(void)
+{
+ return (size_t) (_binary_blocks_end - _binary_blocks_start);
+}
+
+#endif
diff --git a/src/blocks/blocks.dat b/src/blocks/blocks.dat
new file mode 100644
index 000000000..249956e75
--- /dev/null
+++ b/src/blocks/blocks.dat
Binary files differ
diff --git a/src/blocks/blocks.h b/src/blocks/blocks.h
new file mode 100644
index 000000000..76a08c89d
--- /dev/null
+++ b/src/blocks/blocks.h
@@ -0,0 +1,16 @@
+#ifndef SRC_BLOCKS_BLOCKS_H_
+#define SRC_BLOCKS_BLOCKS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const unsigned char *get_blocks_dat_start();
+size_t get_blocks_dat_size();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* SRC_BLOCKS_BLOCKS_H_ */