PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_cpu.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_cpu.h
4 * Runtime CPU feature detection
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/port/pg_cpu.h
10 *
11 *-------------------------------------------------------------------------
12 */
13#ifndef PG_CPU_H
14#define PG_CPU_H
15
16#if defined(USE_SSE2) || defined(__i386__)
17
18typedef enum X86FeatureId
19{
20 /* Have we run feature detection? */
22
23 /* scalar registers and 128-bit XMM registers */
26
27 /* 256-bit YMM registers */
28 PG_AVX2,
29
30 /* 512-bit ZMM registers */
35
36 /* identification */
38
39 /* Time-Stamp Counter (TSC) flags */
44#define X86FeaturesSize (PG_TSC_ADJUST + 1)
45
46extern PGDLLIMPORT bool X86Features[];
47
48extern void set_x86_features(void);
49
50static inline bool
52{
53 if (X86Features[INIT_PG_X86] == false)
55
56 return X86Features[feature];
57}
58
59extern uint32 x86_tsc_frequency_khz(void);
60
61#endif /* defined(USE_SSE2) || defined(__i386__) */
62
63#endif /* PG_CPU_H */
#define PGDLLIMPORT
Definition c.h:1421
uint32_t uint32
Definition c.h:624
static int fb(int x)