1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #1529 from LudwigOrtmann/cpuid_fixup

tests, native: fixup for cpuid
This commit is contained in:
Ludwig Ortmann 2014-08-05 18:40:49 +02:00
commit 3912e5e632
4 changed files with 17 additions and 10 deletions

View File

@ -60,6 +60,8 @@
/** /**
* @brief length of CPU ID for @ref cpu_id_get() in @ref periph/cpuid.h * @brief length of CPU ID for @ref cpu_id_get() in @ref periph/cpuid.h
*/ */
#ifndef CPUID_ID_LEN
#define CPUID_ID_LEN (4) #define CPUID_ID_LEN (4)
#endif
#endif /* CPUCONF_H_ */ #endif /* CPUCONF_H_ */

View File

@ -1,9 +1,9 @@
/* /*
* Copyright (C) 2014 Martin Lenders <mlenders@inf.fu-berlin.de> * Copyright (C) 2014 Martin Lenders <mlenders@inf.fu-berlin.de>
* *
* This file is subject to the terms and conditions of the GNU Lesser General * This file is subject to the terms and conditions of the GNU Lesser
* Public License. See the file LICENSE in the top level directory for more * General Public License v2.1. See the file LICENSE in the top level
* details. * directory for more details.
*/ */
/** /**
@ -26,9 +26,14 @@
void cpuid_get(void *id) void cpuid_get(void *id)
{ {
memset(id, 0xff, CPUID_ID_LEN); /* Just in case _native_id is shorter /* Just in case _native_id is shorter than CPUID_ID_LEN: */
than CPUID_ID_LEN. */ size_t len = CPUID_ID_LEN;
memcpy(id, &(_native_id), sizeof(_native_id)); if (sizeof(_native_id) < CPUID_ID_LEN) {
memset(((char*)id) + sizeof(_native_id), 0xff,
CPUID_ID_LEN - sizeof(_native_id));
len = sizeof(_native_id);
}
memcpy(id, &(_native_id), len);
} }
/** /**

View File

@ -1,4 +1,4 @@
export APPLICATION = test_cpu_id export APPLICATION = cpu_id
include ../Makefile.tests_common include ../Makefile.tests_common
BOARD_WHITELIST := native BOARD_WHITELIST := native

View File

@ -1,9 +1,9 @@
/* /*
* Copyright (C) 2014 Freie Universität Berlin * Copyright (C) 2014 Freie Universität Berlin
* *
* This file is subject to the terms and conditions of the GNU Lesser General * This file is subject to the terms and conditions of the GNU Lesser
* Public License. See the file LICENSE in the top level directory for more * General Public License v2.1. See the file LICENSE in the top level
* details. * directory for more details.
*/ */
/** /**