* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
+#include "qemu/osdep.h"
#include "qemu.h"
-//#include "qemu-common.h"
+#include "user-internals.h"
#include "uname.h"
/* return highest utsname machine name for emulated instruction set
* NB: the default emulated CPU ("any") might not match any existing CPU, e.g.
* on ARM it has all features turned on, so there is no perfect arch string to
* return here */
-const char *cpu_to_uname_machine(void *cpu_env)
+const char *cpu_to_uname_machine(CPUArchState *cpu_env)
{
#if defined(TARGET_ARM) && !defined(TARGET_AARCH64)
/* in theory, endianness is configurable on some ARM CPUs, but this isn't
* used in user mode emulation */
-#ifdef TARGET_WORDS_BIGENDIAN
+#if TARGET_BIG_ENDIAN
#define utsname_suffix "b"
#else
#define utsname_suffix "l"
/* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its
* Jazelle support */
return "armv5te" utsname_suffix;
-#elif defined(TARGET_X86_64)
- return "x86-64";
-#elif defined(TARGET_I386)
+#elif defined(TARGET_I386) && !defined(TARGET_X86_64)
/* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */
- CPUState *cpu = ENV_GET_CPU((CPUX86State *)cpu_env);
+ CPUState *cpu = env_cpu(cpu_env);
int family = object_property_get_int(OBJECT(cpu), "family", NULL);
if (family == 4) {
return "i486";
#define COPY_UTSNAME_FIELD(dest, src) \
do { \
- /* __NEW_UTS_LEN doesn't include terminating null */ \
- (void) strncpy((dest), (src), __NEW_UTS_LEN); \
- (dest)[__NEW_UTS_LEN] = '\0'; \
+ memcpy((dest), (src), MIN(sizeof(src), sizeof(dest))); \
+ (dest)[sizeof(dest) - 1] = '\0'; \
} while (0)
int sys_uname(struct new_utsname *buf)