Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1024)

Unified Diff: src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c

Issue 2255006: StatefulMem* functions should be library functions. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c
diff --git a/src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c b/src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c
new file mode 100644
index 0000000000000000000000000000000000000000..4727eab9a0caf5394e8eedc3df6478b2e25ac773
--- /dev/null
+++ b/src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c
@@ -0,0 +1,55 @@
+/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Stub implementations of utility functions which call their linux-specific
+ * equivalents.
+ */
+
+#include "stateful_util.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void* StatefulMemcpy(MemcpyState* state, void* dst,
+ uint64_t len) {
+ if (state->overrun)
+ return NULL;
+ if (len > state->remaining_len) {
+ state->overrun = 1;
+ return NULL;
+ }
+ Memcpy(dst, state->remaining_buf, len);
+ state->remaining_buf += len;
+ state->remaining_len -= len;
+ return dst;
+}
+
+const void* StatefulMemcpy_r(MemcpyState* state, const void* src,
+ uint64_t len) {
+ if (state->overrun)
+ return NULL;
+ if (len > state->remaining_len) {
+ state->overrun = 1;
+ return NULL;
+ }
+ Memcpy(state->remaining_buf, src, len);
+ state->remaining_buf += len;
+ state->remaining_len -= len;
+ return src;
+}
+
+const void* StatefulMemset_r(MemcpyState* state, const uint8_t val,
+ uint64_t len) {
+ if (state->overrun)
+ return NULL;
+ if (len > state->remaining_len) {
+ state->overrun = 1;
+ return NULL;
+ }
+ Memset(state->remaining_buf, val, len);
+ state->remaining_buf += len;
+ state->remaining_len -= len;
+ return state; // have to return something non-NULL
+}

Powered by Google App Engine
This is Rietveld 408576698