Moved toward elimination of shared library usages.

This commit is contained in:
2015-09-06 21:20:19 -05:00
parent d91d9370eb
commit 800d321004
4 changed files with 25 additions and 6 deletions
+2
View File
@@ -10,6 +10,8 @@ add_definitions(
-Wall -Wall
-Wsign-compare -Wsign-compare
-nostdlib -nostdlib
-fno-exceptions
-fno-rtti
#-Werror #-Werror
#--analyze #--analyze
#-Os # GCC size optimization flag #-Os # GCC size optimization flag
+13 -4
View File
@@ -5,7 +5,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <string.h> #include <stdlib.h>
#include "_memops.hpp" #include "_memops.hpp"
#include "memfs.hpp" #include "memfs.hpp"
@@ -28,9 +28,18 @@ void MemFs::Record::setData(uint8_t *data, int size) {
m_data = size; m_data = size;
} }
MemFs::MemFs(uint8_t *begin, uint8_t *end): m_version(*((uint32_t*) begin)), m_lastRec(*(MemFsPtr*) (begin + sizeof(m_version))) {
if (version != m_version) { // MemFs
throw "MemFs version mismatch";
MemFs::MemFs(uint8_t *begin, uint8_t *end, uint32_t *error): m_version(*((uint32_t*) begin)), m_lastRec(*(MemFsPtr*) (begin + sizeof(m_version))) {
if (error) {
if (version != m_version) {
// version mismatch
*error = 1;
} else {
// ok
*error = 0;
}
} }
m_begin = begin; m_begin = begin;
m_end = end; m_end = end;
+2 -2
View File
@@ -8,7 +8,6 @@
#ifndef MEMPHIS_MEMFS_HPP #ifndef MEMPHIS_MEMFS_HPP
#define MEMPHIS_MEMFS_HPP #define MEMPHIS_MEMFS_HPP
#include <string>
#include "types.hpp" #include "types.hpp"
namespace memphis { namespace memphis {
@@ -46,8 +45,9 @@ class MemFs {
* Constructor * Constructor
* @param begin pointer to the beginning of this MemFs's memory chunk * @param begin pointer to the beginning of this MemFs's memory chunk
* @param end pointer to the end of this MemFs's memory chunk * @param end pointer to the end of this MemFs's memory chunk
* @param error pointer to a integer return errors into
*/ */
MemFs(uint8_t *begin, uint8_t *end); MemFs(uint8_t *begin, uint8_t *end, uint32_t *error = nullptr);
/** /**
* Initializes the memory chunk of this MemFs was given. * Initializes the memory chunk of this MemFs was given.
+8
View File
@@ -15,10 +15,18 @@ typedef unsigned char uint8_t;
typedef short int16_t; typedef short int16_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef int int32_t; typedef int int32_t;
typedef unsigned int uint32_t;
typedef unsigned uint_t; typedef unsigned uint_t;
typedef long long int64_t; typedef long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
#ifdef _LP64
typedef uint64_t size_t;
#elif _LP32
typedef uint32_t size_t;
#endif
} }
#endif #endif