70 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) |
70 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) |
71 typedef __u64 u_int64_t; |
71 typedef __u64 u_int64_t; |
72 typedef __s64 int64_t; |
72 typedef __s64 int64_t; |
73 #endif |
73 #endif |
74 |
74 |
75 typedef uint8_t __be8; |
75 typedef uint8_t __be8; |
76 typedef uint16_t __be16; |
76 typedef uint16_t __be16; |
77 typedef uint32_t __be32; |
77 typedef uint32_t __be32; |
78 typedef uint64_t __be64; |
78 typedef uint64_t __be64; |
79 |
79 |
80 /* Size of a pointer */ |
80 /* Size of a pointer */ |
81 #if defined(_LP64) || defined(_I32LPx) |
81 #if defined(_LP64) || defined(_I32LPx) |
82 #define __WORDSIZE 64 |
82 #define __WORDSIZE 64 |
83 #else |
83 #else |
84 #define __WORDSIZE 32 |
84 #define __WORDSIZE 32 |
85 #endif |
85 #endif |
86 |
86 |
87 |
87 |
88 /* |
88 /* |
89 * Endian definitions |
89 * Endian definitions |
90 */ |
90 */ |
91 #define __LITTLE_ENDIAN 1234 |
91 #define __LITTLE_ENDIAN 1234 |
92 #define __BIG_ENDIAN 4321 |
92 #define __BIG_ENDIAN 4321 |
93 |
93 |
94 #ifdef _BIG_ENDIAN |
94 #ifdef _BIG_ENDIAN |
95 #define __BYTE_ORDER __BIG_ENDIAN |
95 #define __BYTE_ORDER __BIG_ENDIAN |
96 #elif defined _LITTLE_ENDIAN |
96 #elif defined _LITTLE_ENDIAN |
97 #define __BYTE_ORDER __LITTLE_ENDIAN |
97 #define __BYTE_ORDER __LITTLE_ENDIAN |
98 #else |
98 #else |
99 #error unknown endianness |
99 #error unknown endianness |
100 #endif |
100 #endif |
101 |
101 |
102 /* |
102 /* |
103 * byteswap functions. |
103 * byteswap functions. |
104 */ |
104 */ |
105 #define bswap_8(x) ((x) & 0xff) |
105 #define bswap_8(x) ((x) & 0xff) |
106 |
106 |
107 #if !defined(__i386) && !defined(__amd64) |
107 #if !defined(__i386) && !defined(__amd64) |
108 #define bswap_16(x) ((bswap_8(x) << 8) | bswap_8((x) >> 8)) |
108 #define bswap_16(x) ((bswap_8(x) << 8) | bswap_8((x) >> 8)) |
109 #define bswap_32(x) (((uint32_t)(x) << 24) | \ |
109 #define bswap_32(x) (((uint32_t)(x) << 24) | \ |
110 (((uint32_t)(x) << 8) & 0xff0000) | \ |
110 (((uint32_t)(x) << 8) & 0xff0000) | \ |
111 (((uint32_t)(x) >> 8) & 0xff00) | \ |
111 (((uint32_t)(x) >> 8) & 0xff00) | \ |
112 ((uint32_t)(x) >> 24)) |
112 ((uint32_t)(x) >> 24)) |
113 #else /* x86 */ |
113 #else /* x86 */ |
114 #define bswap_16(x) htons(x) |
114 #define bswap_16(x) htons(x) |
115 #define bswap_32(x) htonl(x) |
115 #define bswap_32(x) htonl(x) |
116 #endif /* !__i386 && !__amd64 */ |
116 #endif /* !__i386 && !__amd64 */ |
117 |
117 |
118 #if defined(_LP64) || defined(_LONGLONG_TYPE) |
118 #if defined(_LP64) || defined(_LONGLONG_TYPE) |
119 #if (!defined(__i386) && !defined(__amd64)) |
119 #if (!defined(__i386) && !defined(__amd64)) |
120 #define bswap_64(x) (((uint64_t)(x) << 56) | \ |
120 #define bswap_64(x) (((uint64_t)(x) << 56) | \ |
121 (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \ |
121 (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \ |
122 (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \ |
122 (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \ |
123 (((uint64_t)(x) << 8) & 0xff00000000ULL) | \ |
123 (((uint64_t)(x) << 8) & 0xff00000000ULL) | \ |
124 (((uint64_t)(x) >> 8) & 0xff000000ULL) | \ |
124 (((uint64_t)(x) >> 8) & 0xff000000ULL) | \ |
125 (((uint64_t)(x) >> 24) & 0xff0000ULL) | \ |
125 (((uint64_t)(x) >> 24) & 0xff0000ULL) | \ |
126 (((uint64_t)(x) >> 40) & 0xff00ULL) | \ |
126 (((uint64_t)(x) >> 40) & 0xff00ULL) | \ |
127 ((uint64_t)(x) >> 56)) |
127 ((uint64_t)(x) >> 56)) |
128 #else /* x86 */ |
128 #else /* x86 */ |
129 #define bswap_64(x) htonll(x) |
129 #define bswap_64(x) htonll(x) |
130 #endif /* !__i386 && !__amd64 */ |
130 #endif /* !__i386 && !__amd64 */ |
131 #else /* no uint64_t */ |
131 #else /* no uint64_t */ |
132 #define bswap_64(x) ((bswap_32(x) << 32) | bswap_32((x) >> 32)) |
132 #define bswap_64(x) ((bswap_32(x) << 32) | bswap_32((x) >> 32)) |
133 #endif |
133 #endif |
134 |
134 |
135 typedef struct sol_cpu_info_s { |
135 typedef struct sol_cpu_info_s { |
136 char cpu_name[64]; |
136 char cpu_name[64]; |
137 uint_t cpu_mhz; |
137 uint_t cpu_mhz; |
138 uint_t cpu_num; |
138 uint_t cpu_number; |
139 } sol_cpu_info_t; |
139 } sol_cpu_info_t; |
140 |
140 |
141 int sol_get_cpu_info(sol_cpu_info_t *); |
141 int sol_get_cpu_info(sol_cpu_info_t **); |
|
142 |
|
143 typedef struct sol_cpu_stats_s { |
|
144 uint64_t t_user; |
|
145 uint64_t t_kernel; |
|
146 uint64_t t_idle; |
|
147 uint64_t t_iowait; |
|
148 uint64_t t_intr; |
|
149 } sol_cpu_stats_t; |
|
150 |
|
151 int sol_get_cpu_stats(sol_cpu_stats_t *); |
|
152 |
|
153 void solaris_init(void); |
|
154 void solaris_fini(void); |
142 |
155 |
143 #ifdef __cplusplus |
156 #ifdef __cplusplus |
144 } |
157 } |
145 #endif |
158 #endif |
146 |
159 |