Added SILC CPUID API
[runtime.git] / lib / silcutil / silccpuid.h
1 /*
2
3   silccpuid.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2008 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef SILCCPUID_H
21 #define SILCCPUID_H
22
23 /****d* silcutil/SilcCPUIdFeatures
24  *
25  * NAME
26  *
27  *    typedef enum { ... } SilcCPUIdFeatures;
28  *
29  * DESCRIPTION
30  *
31  *    CPU features.  Indicates which instruction sets the CPU supports.
32  *
33  */
34 typedef enum {
35   SILC_CPUID_UNKNOWN     = 0x00000000,           /* 386 only */
36   SILC_CPUID_386         = 0x00000002,           /* 386 */
37   SILC_CPUID_MMX         = 0x00000004,           /* MMX */
38   SILC_CPUID_CMOV        = 0x00000008,           /* CMOV, FCOMI */
39   SILC_CPUID_SSE         = 0x00000010,           /* SSE */
40   SILC_CPUID_SSE2        = 0x00000020,           /* SSE2 */
41   SILC_CPUID_SSE3        = 0x00000040,           /* SSE3 */
42   SILC_CPUID_SSSE3       = 0x00000080,           /* SSSE3 */
43   SILC_CPUID_SSE41       = 0x00000100,           /* SSE4.1 */
44   SILC_CPUID_SSE42       = 0x00000200,           /* SSE4.2 */
45   SILC_CPUID_SSE4A       = 0x00000400,           /* SSE4a */
46   SILC_CPUID_SSE5        = 0x00000800,           /* SSE5 */
47   SILC_CPUID_AVX         = 0x00001000,           /* AVX */
48   SILC_CPUID_AES         = 0x00002000,           /* AES */
49 } SilcCPUIdFeatures;
50 /***/
51
52 /****f* silcutil/silc_cpuid_features
53  *
54  * SYNOPSIS
55  *
56  *    SilcCPUIdFeatures silc_cpuid_features(void);
57  *
58  * DESCRIPTION
59  *
60  *    Returns the CPU instruction set features.  The ID can be used to
61  *    determine what features the CPU supports.  The returned value is a
62  *    bitmask of supported features.
63  *
64  * NOTES
65  *
66  *    This function should not be called at a code path where speed is
67  *    critical.  It is recommended to call this once and later use the
68  *    returned value to determine features.
69  *
70  *    This function works only on x86 or x86-64 CPUs.
71  *
72  ***/
73 SilcCPUIdFeatures silc_cpuid_features(void);
74
75 #endif /* SILCCPUID_H */