Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

od: quick-fix for newlib-nano #6080

Merged
merged 1 commit into from
Nov 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sys/include/od.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ extern "C" {
#define OD_FLAGS_LENGTH_1 (0x0010) /**< 1 byte */
#define OD_FLAGS_LENGTH_2 (0x0020) /**< 2 byte */
#define OD_FLAGS_LENGTH_4 (0x0000) /**< 4 byte and default */
#define OD_FLAGS_LENGTH_8 (0x0080) /**< 8 byte */
/**
* @brief 8 byte
*
* @warning not working with newlib-nano
*/
#define OD_FLAGS_LENGTH_8 (0x0080)
#define OD_FLAGS_LENGTH_CHAR (OD_FLAGS_LENGTH_1) /**< alias for OD_FLAGS_LENGTH_1 */
#define OD_FLAGS_LENGTH_SHORT (0x0002) /**< sizeof(short) byte */
#define OD_FLAGS_LENGTH_LONG (0x0004) /**< sizeof(long) byte */
Expand Down
4 changes: 4 additions & 0 deletions sys/od/od.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,16 @@ static void _print_date(const void *data, size_t offset, char *format, uint8_t l
break;

case 8:
#ifndef MODULE_NEWLIB
if (flags & OD_FLAGS_BYTES_INT) {
printf(format, ((int64_t *)data)[offset]);
}
else {
printf(format, ((uint64_t *)data)[offset]);
}
#else
printf("%s", format);
#endif

break;

Expand Down
2 changes: 2 additions & 0 deletions tests/od/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ int main(void)
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_4));

/* Test different 8-byte-wise byte formats */
#ifndef MODULE_NEWLIB
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_8));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
Expand All @@ -151,6 +152,7 @@ int main(void)
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_8));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_8));
#endif

/* Test different char-wise byte formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
Expand Down
3 changes: 3 additions & 0 deletions tests/od/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import testrunner

def testfunc(child):
# check if running with newlib
print("ATTENTION: This script is currently not suitable for non-native platforms")

# test data width vs. output width discrepency
child.expect_exact(r'od(short_str, sizeof(short_str), OD_WIDTH_DEFAULT, 0)')
child.expect_exact(r'000000000 000000041101')
Expand Down