JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 3: Extended Library Functions     Oracle Solaris 10 1/13 Information Library
search filter icon
search icon

Document Information

Preface

Extended Library Functions - Part 1

acl_check(3SEC)

aclcheck(3SEC)

acl_free(3SEC)

aclfrommode(3SEC)

acl_fromtext(3SEC)

aclfromtext(3SEC)

acl_get(3SEC)

acl_set(3SEC)

aclsort(3SEC)

acl_strip(3SEC)

acltomode(3SEC)

acl_totext(3SEC)

acltotext(3SEC)

acl_trivial(3SEC)

acos(3M)

acosf(3M)

acosh(3M)

acoshf(3M)

acoshl(3M)

acosl(3M)

advance(3GEN)

asin(3M)

asinf(3M)

asinh(3M)

asinhf(3M)

asinhl(3M)

asinl(3M)

atan2(3M)

atan2f(3M)

atan2l(3M)

atan(3M)

atanf(3M)

atanh(3M)

atanhf(3M)

atanhl(3M)

atanl(3M)

au_close(3BSM)

au_open(3BSM)

au_preselect(3BSM)

au_to(3BSM)

au_to_arg32(3BSM)

au_to_arg(3BSM)

au_to_arg64(3BSM)

au_to_attr(3BSM)

au_to_cmd(3BSM)

au_to_data(3BSM)

auto_ef(3EXT)

auto_ef_file(3EXT)

auto_ef_free(3EXT)

auto_ef_get_encoding(3EXT)

auto_ef_get_score(3EXT)

auto_ef_str(3EXT)

au_to_groups(3BSM)

au_to_in_addr(3BSM)

au_to_ipc(3BSM)

au_to_iport(3BSM)

au_to_me(3BSM)

au_to_newgroups(3BSM)

au_to_opaque(3BSM)

au_to_path(3BSM)

au_to_process(3BSM)

au_to_process_ex(3BSM)

au_to_return32(3BSM)

au_to_return(3BSM)

au_to_return64(3BSM)

au_to_socket(3BSM)

au_to_subject(3BSM)

au_to_subject_ex(3BSM)

au_to_text(3BSM)

au_user_mask(3BSM)

au_write(3BSM)

bcleartoh(3TSOL)

bcleartoh_r(3TSOL)

bcleartos(3TSOL)

bgets(3GEN)

blcompare(3TSOL)

bldominates(3TSOL)

blequal(3TSOL)

blinrange(3TSOL)

blmaximum(3TSOL)

blminimum(3TSOL)

blminmax(3TSOL)

blstrictdom(3TSOL)

bltocolor(3TSOL)

bltocolor_r(3TSOL)

bltos(3TSOL)

bsltoh(3TSOL)

bsltoh_r(3TSOL)

bsltos(3TSOL)

btohex(3TSOL)

bufsplit(3GEN)

cabs(3M)

cabsf(3M)

cabsl(3M)

cacos(3M)

cacosf(3M)

cacosh(3M)

cacoshf(3M)

cacoshl(3M)

cacosl(3M)

carg(3M)

cargf(3M)

cargl(3M)

casin(3M)

casinf(3M)

casinh(3M)

casinhf(3M)

casinhl(3M)

casinl(3M)

catan(3M)

catanf(3M)

catanh(3M)

catanhf(3M)

catanhl(3M)

catanl(3M)

cbrt(3M)

cbrtf(3M)

cbrtl(3M)

ccos(3M)

ccosf(3M)

ccosh(3M)

ccoshf(3M)

ccoshl(3M)

ccosl(3M)

ceil(3M)

ceilf(3M)

ceill(3M)

cexp(3M)

cexpf(3M)

cexpl(3M)

cfc_file_start(3TECLA)

cfc_literal_escapes(3TECLA)

cfc_set_check_fn(3TECLA)

chkauthattr(3SECDB)

cimag(3M)

cimagf(3M)

cimagl(3M)

clog(3M)

clogf(3M)

clogl(3M)

compile(3GEN)

config_admin(3CFGADM)

config_ap_id_cmp(3CFGADM)

config_change_state(3CFGADM)

config_list(3CFGADM)

config_list_ext(3CFGADM)

config_private_func(3CFGADM)

config_stat(3CFGADM)

config_strerror(3CFGADM)

config_test(3CFGADM)

config_unload_libs(3CFGADM)

conj(3M)

conjf(3M)

conjl(3M)

ConnectToServer(3DMI)

copylist(3GEN)

copysign(3M)

copysignf(3M)

copysignl(3M)

cos(3M)

cosf(3M)

cosh(3M)

coshf(3M)

coshl(3M)

cosl(3M)

cpc(3CPC)

cpc_access(3CPC)

cpc_bind_cpu(3CPC)

cpc_bind_curlwp(3CPC)

cpc_bind_event(3CPC)

cpc_bind_pctx(3CPC)

cpc_buf_add(3CPC)

cpc_buf_copy(3CPC)

cpc_buf_create(3CPC)

cpc_buf_destroy(3CPC)

cpc_buf_get(3CPC)

cpc_buf_hrtime(3CPC)

cpc_buf_set(3CPC)

cpc_buf_sub(3CPC)

cpc_buf_tick(3CPC)

cpc_buf_zero(3CPC)

cpc_caps(3CPC)

cpc_cciname(3CPC)

cpc_close(3CPC)

cpc_count_sys_events(3CPC)

cpc_count_usr_events(3CPC)

cpc_cpuref(3CPC)

cpc_disable(3CPC)

cpc_enable(3CPC)

cpc_event(3CPC)

cpc_event_accum(3CPC)

cpc_event_diff(3CPC)

cpc_eventtostr(3CPC)

cpc_getcciname(3CPC)

cpc_getcpuref(3CPC)

cpc_getcpuver(3CPC)

cpc_getnpic(3CPC)

cpc_getusage(3CPC)

cpc_npic(3CPC)

cpc_open(3CPC)

cpc_pctx_bind_event(3CPC)

cpc_pctx_invalidate(3CPC)

cpc_pctx_rele(3CPC)

cpc_pctx_take_sample(3CPC)

cpc_rele(3CPC)

cpc_request_preset(3CPC)

cpc_set_add_request(3CPC)

cpc_set_create(3CPC)

cpc_set_destroy(3CPC)

cpc_seterrfn(3CPC)

cpc_seterrhndlr(3CPC)

cpc_set_restart(3CPC)

cpc_set_sample(3CPC)

cpc_shared_bind_event(3CPC)

cpc_shared_close(3CPC)

cpc_shared_open(3CPC)

cpc_shared_rele(3CPC)

cpc_shared_take_sample(3CPC)

cpc_strtoevent(3CPC)

cpc_take_sample(3CPC)

cpc_unbind(3CPC)

cpc_version(3CPC)

cpc_walk_attrs(3CPC)

cpc_walk_events_all(3CPC)

cpc_walk_events_pic(3CPC)

cpc_walk_names(3CPC)

cpc_walk_requests(3CPC)

cpl_add_completion(3TECLA)

cpl_check_exe(3TECLA)

cpl_complete_word(3TECLA)

cpl_file_completions(3TECLA)

cpl_last_error(3TECLA)

cpl_list_completions(3TECLA)

cpl_recall_matches(3TECLA)

cpl_record_error(3TECLA)

cplus_demangle(3EXT)

cpow(3M)

cpowf(3M)

cpowl(3M)

cproj(3M)

cprojf(3M)

cprojl(3M)

creal(3M)

crealf(3M)

creall(3M)

csin(3M)

csinf(3M)

csinh(3M)

csinhf(3M)

csinhl(3M)

csinl(3M)

csqrt(3M)

csqrtf(3M)

csqrtl(3M)

ctan(3M)

ctanf(3M)

ctanh(3M)

ctanhf(3M)

ctanhl(3M)

ctanl(3M)

ct_ctl_abandon(3CONTRACT)

ct_ctl_ack(3CONTRACT)

ct_ctl_adopt(3CONTRACT)

ct_ctl_newct(3CONTRACT)

ct_ctl_qack(3CONTRACT)

ct_event_free(3CONTRACT)

ct_event_get_ctid(3CONTRACT)

ct_event_get_evid(3CONTRACT)

ct_event_get_flags(3CONTRACT)

ct_event_get_nevid(3CONTRACT)

ct_event_get_newct(3CONTRACT)

ct_event_get_type(3CONTRACT)

ct_event_read(3CONTRACT)

ct_event_read_critical(3CONTRACT)

ct_event_reliable(3CONTRACT)

ct_event_reset(3CONTRACT)

ct_pr_event_get_exitstatus(3CONTRACT)

ct_pr_event_get_gcorefile(3CONTRACT)

ct_pr_event_get_pcorefile(3CONTRACT)

ct_pr_event_get_pid(3CONTRACT)

ct_pr_event_get_ppid(3CONTRACT)

ct_pr_event_get_sender(3CONTRACT)

ct_pr_event_get_senderct(3CONTRACT)

ct_pr_event_get_signal(3CONTRACT)

ct_pr_event_get_zcorefile(3CONTRACT)

ct_pr_status_get_contracts(3CONTRACT)

ct_pr_status_get_fatal(3CONTRACT)

ct_pr_status_get_members(3CONTRACT)

ct_pr_status_get_param(3CONTRACT)

ct_pr_tmpl_get_fatal(3CONTRACT)

ct_pr_tmpl_get_param(3CONTRACT)

ct_pr_tmpl_get_transfer(3CONTRACT)

ct_pr_tmpl_set_fatal(3CONTRACT)

ct_pr_tmpl_set_param(3CONTRACT)

ct_pr_tmpl_set_transfer(3CONTRACT)

ct_status_free(3CONTRACT)

ct_status_get_cookie(3CONTRACT)

ct_status_get_critical(3CONTRACT)

ct_status_get_holder(3CONTRACT)

ct_status_get_id(3CONTRACT)

ct_status_get_informative(3CONTRACT)

ct_status_get_nevents(3CONTRACT)

ct_status_get_nevid(3CONTRACT)

ct_status_get_ntime(3CONTRACT)

ct_status_get_qtime(3CONTRACT)

ct_status_get_state(3CONTRACT)

ct_status_get_type(3CONTRACT)

ct_status_get_zoneid(3CONTRACT)

ct_status_read(3CONTRACT)

ct_tmpl_activate(3CONTRACT)

ct_tmpl_clear(3CONTRACT)

ct_tmpl_create(3CONTRACT)

ct_tmpl_get_cookie(3CONTRACT)

ct_tmpl_get_critical(3CONTRACT)

ct_tmpl_get_informative(3CONTRACT)

ct_tmpl_set_cookie(3CONTRACT)

ct_tmpl_set_critical(3CONTRACT)

ct_tmpl_set_informative(3CONTRACT)

dat_cno_create(3DAT)

dat_cno_free(3DAT)

dat_cno_modify_agent(3DAT)

dat_cno_query(3DAT)

dat_cno_wait(3DAT)

dat_cr_accept(3DAT)

dat_cr_handoff(3DAT)

dat_cr_query(3DAT)

dat_cr_reject(3DAT)

dat_ep_connect(3DAT)

dat_ep_create(3DAT)

dat_ep_create_with_srq(3DAT)

dat_ep_disconnect(3DAT)

dat_ep_dup_connect(3DAT)

dat_ep_free(3DAT)

dat_ep_get_status(3DAT)

dat_ep_modify(3DAT)

dat_ep_post_rdma_read(3DAT)

dat_ep_post_rdma_write(3DAT)

dat_ep_post_recv(3DAT)

dat_ep_post_send(3DAT)

dat_ep_query(3DAT)

dat_ep_recv_query(3DAT)

dat_ep_reset(3DAT)

dat_ep_set_watermark(3DAT)

dat_evd_clear_unwaitable(3DAT)

dat_evd_dequeue(3DAT)

dat_evd_disable(3DAT)

dat_evd_enable(3DAT)

dat_evd_free(3DAT)

dat_evd_modify_cno(3DAT)

dat_evd_post_se(3DAT)

dat_evd_query(3DAT)

dat_evd_resize(3DAT)

dat_evd_set_unwaitable(3DAT)

dat_evd_wait(3DAT)

dat_get_consumer_context(3DAT)

dat_get_handle_type(3DAT)

dat_ia_close(3DAT)

dat_ia_open(3DAT)

dat_ia_query(3DAT)

dat_lmr_create(3DAT)

dat_lmr_free(3DAT)

dat_lmr_query(3DAT)

Extended Library Functions - Part 2

Extended Library Functions - Part 3

Extended Library Functions - Part 4

Extended Library Functions - Part 5

Extended Library Functions - Part 6

cpc_buf_create

, cpc_buf_destroy

, cpc_set_sample

, cpc_buf_get

, cpc_buf_set

, cpc_buf_hrtime

, cpc_buf_tick

, cpc_buf_sub

, cpc_buf_add

, cpc_buf_copy

, cpc_buf_zero

- sample and manipulate CPC data

Synopsis

cc [ flag… ] file-lcpc [ library… ] 
#include <libcpc.h>

cpc_buf_t *cpc_buf_create(cpc_t *cpc, cpc_set_t *set);
int cpc_buf_destroy(cpc_t *cpc, cpc_buf_t *buf);
int cpc_set_sample(cpc_t *cpc, cpc_set_t *set, cpc_buf_t *buf);
int cpc_buf_get(cpc_t *cpc, cpc_buf_t *buf, int index, uint64_t *val);
int cpc_buf_set(cpc_t *cpc, cpc_buf_t *buf, int index, uint64_t val);
hrtime_t cpc_buf_hrtime(cpc_t *cpc, cpc_buf_t *buf);
uint64_t cpc_buf_tick(cpc_t *cpc, cpc_buf_t *buf);
void cpc_buf_sub(cpc_t *cpc, cpc_buf_t *ds, cpc_buf_t *a, cpc_buf_t *b);
void cpc_buf_add(cpc_t *cpc, cpc_buf_t *ds, cpc_buf_t *a, cpc_buf_t *b);
void cpc_buf_copy(cpc_t *cpc, cpc_buf_t *ds, cpc_buf_t *src);
void cpc_buf_zero(cpc_t *cpc, cpc_buf_t *buf);

Description

Counter data is sampled into CPC buffers, which are represented by the opaque data type cpc_buf_t. A CPC buffer is created with cpc_buf_create() to hold the data for a specific CPC set. Once a CPC buffer has been created, it can only be used to store and manipulate the data of the CPC set for which it was created.

Once a set has been successfully bound, the counter values are sampled using cpc_set_sample(). The cpc_set_sample() function takes a snapshot of the hardware performance counters counting on behalf of the requests in set and stores the 64-bit virtualized software representations of the counters in the supplied CPC buffer. If a set was bound with cpc_bind_curlwp(3CPC) or cpc_bind_curlwp(3CPC), the set can only be sampled by the LWP that bound it.

The kernel maintains 64-bit virtual software counters to hold the counts accumulated for each request in the set, thereby allowing applications to count past the limits of the underlying physical counter, which can be significantly smaller than 64 bits. The kernel attempts to maintain the full 64-bit counter values even in the face of physical counter overflow on architectures and processors that can automatically detect overflow. If the processor is not capable of overflow detection, the caller must ensure that the counters are sampled often enough to avoid the physical counters wrapping. The events most prone to wrap are those that count processor clock cycles. If such an event is of interest, sampling should occur frequently so that the counter does not wrap between samples.

The cpc_buf_get() function retrieves the last sampled value of a particular request in buf. The index argument specifies which request value in the set to retrieve. The index for each request is returned during set configuration by cpc_set_add_request(3CPC). The 64-bit virtualized software counter value is stored in the location pointed to by the val argument.

The cpc_buf_set() function stores a 64-bit value to a specific request in the supplied buffer. This operation can be useful for performing calculations with CPC buffers, but it does not affect the value of the hardware counter (and thus will not affect the next sample).

The cpc_buf_hrtime() function returns a high-resolution timestamp indicating exactly when the set was last sampled by the kernel.

The cpc_buf_tick() function returns a 64-bit virtualized cycle counter indicating how long the set has been programmed into the counter since it was bound. The units of the values returned by cpc_buf_tick() are CPU clock cycles.

The cpc_buf_sub() function calculates the difference between each request in sets a and b, storing the result in the corresponding request within set ds. More specifically, for each request index n, this function performs ds[n] = a[n] - b[n]. Similarly, cpc_buf_add() adds each request in sets a and b and stores the result in the corresponding request within set ds.

The cpc_buf_copy() function copies each value from buffer src into buffer ds. Both buffers must have been created from the same cpc_set_t.

The cpc_buf_zero() function sets each request's value in the buffer to zero.

The cpc_buf_destroy() function frees all resources associated with the CPC buffer.

Return Values

Upon successful completion, cpc_buf_create() returns a pointer to a CPC buffer which can be used to hold data for the set argument. Otherwise, this function returns NULL and sets errno to indicate the error.

Upon successful completion, cpc_set_sample(), cpc_buf_get(), and cpc_buf_set() return 0. Otherwise, they return -1 and set errno to indicate the error.

Errors

These functions will fail if:

EINVAL

For cpc_set_sample(), the set is not bound, the set and/or CPC buffer were not created with the given cpc handle, or the CPC buffer was not created with the supplied set.

EAGAIN

When using cpc_set_sample() to sample a CPU-bound set, the LWP has been unbound from the processor it is measuring.

ENOMEM

The library could not allocate enough memory for its internal data structures.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Evolving
MT-Level
Safe

See Also

cpc_bind_curlwp(3CPC), cpc_set_add_request(3CPC), libcpc(3LIB), attributes(5)

Notes

Often the overhead of performing a system call can be too disruptive to the events being measured. Once a cpc_bind_curlwp(3CPC) call has been issued, it is possible to access directly the performance hardware registers from within the application. If the performance counter context is active, the counters will count on behalf of the current LWP.

Not all processors support this type of access. On processors where direct access is not possible, cpc_set_sample() must be used to read the counters.

SPARC
rd %pic, %rN        ! All UltraSPARC
wr %rN, %pic        ! (All UltraSPARC, but see text)
x86
rdpmc               ! Pentium II, III, and 4 only

If the counter context is not active or has been invalidated, the %pic register (SPARC), and the rdpmc instruction (Pentium) becomes unavailable.

Pentium II and III processors support the non-privileged rdpmc instruction that requires that the counter of interest be specified in %ecx and return a 40-bit value in the %edx:%eax register pair. There is no non-privileged access mechanism for Pentium I processors.