1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include <stdio.h>
- #include "utils.hpp"
- /*
- * printf:
- * Invokes OCALL to display the enclave buffer to the terminal.
- */
- void printf(const char *fmt, ...)
- {
- char buf[BUFSIZ] = {'\0'};
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, BUFSIZ, fmt, ap);
- va_end(ap);
- ocall_print_string(buf);
- }
- /*
- * printf_with_rtclock:
- * Invokes OCALL to display the enclave buffer to the terminal with a
- * timestamp and returns the timestamp.
- */
- unsigned long printf_with_rtclock(const char *fmt, ...)
- {
- unsigned long ret;
- char buf[BUFSIZ] = {'\0'};
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, BUFSIZ, fmt, ap);
- va_end(ap);
- ocall_print_string_with_rtclock(&ret, buf);
- return ret;
- }
- /*
- * printf_with_rtclock_diff:
- * Invokes OCALL to display the enclave buffer to the terminal with a
- * timestamp and returns the timestamp. Also prints the difference from
- * the before timestamp.
- */
- unsigned long printf_with_rtclock_diff(unsigned long before, const char *fmt, ...)
- {
- unsigned long ret;
- char buf[BUFSIZ] = {'\0'};
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, BUFSIZ, fmt, ap);
- va_end(ap);
- ocall_print_string_with_rtclock_diff(&ret, buf, before);
- return ret;
- }
|