Changeset 2291


Ignore:
Timestamp:
Aug 21, 2005, 12:57:05 AM (20 years ago)
Author:
bird
Message:

memcpy_amd test.

Location:
trunk/src/libctests/libc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libctests/libc/Makefile

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r2290 r2291  
    9090        smoketests/fork-exec-1.c \
    9191        smoketests/kill-children-1.c \
    92         smoketests/kill-children-2.c
     92        smoketests/kill-children-2.c \
     93        smoketests/memcpy-amd-1.c
    9394       
    9495#       smoketests/weak-export-1.c - dll
  • trunk/src/libctests/libc/smoketests/memcpy-amd-1.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r2290 r2291  
    2828#include <string.h>
    2929#include <stdlib.h>
     30#include <stdint.h>
    3031
    3132char abSrc[0x40000];
     
    113114}
    114115
     116/**
     117 * Checks if the current CPU supports CPUID.
     118 *
     119 * @returns 1 if CPUID is supported, 0 if it doesn't.
     120 */
     121static inline int HasCpuId(void)
     122{
     123    int         fRet = 0;
     124    uint32_t    u1;
     125    uint32_t    u2;
     126    __asm__ ("pushf\n\t"
     127             "pop   %1\n\t"
     128             "mov   %1, %2\n\t"
     129             "xorl  $0x200000, %1\n\t"
     130             "push  %1\n\t"
     131             "popf\n\t"
     132             "pushf\n\t"
     133             "pop   %1\n\t"
     134             "cmpl  %1, %2\n\t"
     135             "setne %0\n\t"
     136             "push  %2\n\t"
     137             "popf\n\t"
     138             : "=m" (fRet), "=r" (u1), "=r" (u2));
     139    return fRet;
     140}
     141
     142static int IsAmd(void)
     143{
     144    if (HasCpuId())
     145    {
     146        uint32_t eax, ebx, ecx, edx;
     147        __asm__ __volatile__ ("cpuid" : "=a" (eax), "=d" (edx), "=c" (ecx), "=b" (ebx) : "0" (0));
     148        if (edx == 0x69746e65 && ecx == 0x444d4163 && ebx == 0x68747541)
     149            return 1;
     150    }
     151    return 0;
     152}
     153
    115154int main()
    116155{
    117156    size_t i, j;
     157    if (!IsAmd())
     158    {
     159        printf("amd-memcpy-1: skipping, not right amd cpu\n");
     160        return 0;
     161    }
    118162    init();
    119163
Note: See TracChangeset for help on using the changeset viewer.