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

Document Information

Preface

Extended Library Functions, Volume 1

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)

cbc_crypt(3EXT)

CIRCLEQ_EMPTY(3EXT)

CIRCLEQ_ENTRY(3EXT)

CIRCLEQ_FIRST(3EXT)

CIRCLEQ_FOREACH(3EXT)

CIRCLEQ_FOREACH_REVERSE(3EXT)

CIRCLEQ_HEAD(3EXT)

CIRCLEQ_HEAD_INITIALIZER(3EXT)

CIRCLEQ_INIT(3EXT)

CIRCLEQ_INSERT_AFTER(3EXT)

CIRCLEQ_INSERT_BEFORE(3EXT)

CIRCLEQ_INSERT_HEAD(3EXT)

CIRCLEQ_INSERT_TAIL(3EXT)

CIRCLEQ_LAST(3EXT)

CIRCLEQ_LOOP_NEXT(3EXT)

CIRCLEQ_LOOP_PREV(3EXT)

CIRCLEQ_NEXT(3EXT)

CIRCLEQ_PREV(3EXT)

CIRCLEQ_REMOVE(3EXT)

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)

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_generic_events_all(3CPC)

cpc_walk_generic_events_pic(3CPC)

cpc_walk_names(3CPC)

cpc_walk_requests(3CPC)

cplus_demangle(3EXT)

crypt(3EXT)

crypt_close(3EXT)

ct_ctl_abandon(3CONTRACT)

ct_ctl_ack(3CONTRACT)

ct_ctl_adopt(3CONTRACT)

ct_ctl_nack(3CONTRACT)

ct_ctl_newct(3CONTRACT)

ct_ctl_qack(3CONTRACT)

ct_dev_status_get_aset(3CONTRACT)

ct_dev_status_get_dev_state(3CONTRACT)

ct_dev_status_get_minor(3CONTRACT)

ct_dev_status_get_noneg(3CONTRACT)

ct_dev_tmpl_clear_noneg(3CONTRACT)

ct_dev_tmpl_get_aset(3CONTRACT)

ct_dev_tmpl_get_minor(3CONTRACT)

ct_dev_tmpl_get_noneg(3CONTRACT)

ct_dev_tmpl_set_aset(3CONTRACT)

ct_dev_tmpl_set_minor(3CONTRACT)

ct_dev_tmpl_set_noneg(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_status_get_svc_aux(3CONTRACT)

ct_pr_status_get_svc_creator(3CONTRACT)

ct_pr_status_get_svc_ctid(3CONTRACT)

ct_pr_status_get_svc_fmri(3CONTRACT)

ct_pr_tmpl_get_fatal(3CONTRACT)

ct_pr_tmpl_get_param(3CONTRACT)

ct_pr_tmpl_get_svc_aux(3CONTRACT)

ct_pr_tmpl_get_svc_fmri(3CONTRACT)

ct_pr_tmpl_get_transfer(3CONTRACT)

ct_pr_tmpl_set_fatal(3CONTRACT)

ct_pr_tmpl_set_param(3CONTRACT)

ct_pr_tmpl_set_svc_aux(3CONTRACT)

ct_pr_tmpl_set_svc_fmri(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)

dat_lmr_sync_rdma_read(3DAT)

dat_lmr_sync_rdma_write(3DAT)

dat_provider_fini(3DAT)

dat_provider_init(3DAT)

dat_psp_create(3DAT)

dat_psp_create_any(3DAT)

dat_psp_free(3DAT)

dat_psp_query(3DAT)

dat_pz_create(3DAT)

dat_pz_free(3DAT)

dat_pz_query(3DAT)

dat_registry_add_provider(3DAT)

dat_registry_list_providers(3DAT)

dat_registry_remove_provider(3DAT)

dat_rmr_bind(3DAT)

dat_rmr_create(3DAT)

dat_rmr_free(3DAT)

dat_rmr_query(3DAT)

dat_rsp_create(3DAT)

dat_rsp_free(3DAT)

dat_rsp_query(3DAT)

dat_set_consumer_context(3DAT)

dat_srq_create(3DAT)

dat_srq_free(3DAT)

dat_srq_post_recv(3DAT)

dat_srq_query(3DAT)

dat_srq_resize(3DAT)

dat_srq_set_lw(3DAT)

dat_strerror(3DAT)

demangle(3EXT)

des_crypt(3EXT)

des_encrypt(3EXT)

DES_FAILED(3EXT)

des_setkey(3EXT)

des_setparity(3EXT)

devid_compare(3DEVID)

devid_deviceid_to_nmlist(3DEVID)

devid_free(3DEVID)

devid_free_nmlist(3DEVID)

devid_get(3DEVID)

devid_get_minor_name(3DEVID)

devid_sizeof(3DEVID)

devid_str_decode(3DEVID)

devid_str_encode(3DEVID)

devid_str_free(3DEVID)

devid_valid(3DEVID)

di_binding_name(3DEVINFO)

di_bus_addr(3DEVINFO)

di_child_node(3DEVINFO)

di_compatible_names(3DEVINFO)

di_devfs_minor_path(3DEVINFO)

di_devfs_path(3DEVINFO)

di_devfs_path_free(3DEVINFO)

di_devid(3DEVINFO)

di_devlink_content(3DEVINFO)

di_devlink_dup(3DEVINFO)

di_devlink_fini(3DEVINFO)

di_devlink_free(3DEVINFO)

di_devlink_init(3DEVINFO)

di_devlink_path(3DEVINFO)

di_devlink_type(3DEVINFO)

di_devlink_walk(3DEVINFO)

di_driver_major(3DEVINFO)

di_driver_name(3DEVINFO)

di_driver_ops(3DEVINFO)

di_drv_first_node(3DEVINFO)

di_drv_next_node(3DEVINFO)

di_fini(3DEVINFO)

di_init(3DEVINFO)

di_instance(3DEVINFO)

di_link_next_by_lnode(3DEVINFO)

di_link_next_by_node(3DEVINFO)

di_link_private_get(3DEVINFO)

di_link_private_set(3DEVINFO)

di_link_spectype(3DEVINFO)

di_link_to_lnode(3DEVINFO)

di_lnode_devinfo(3DEVINFO)

di_lnode_devt(3DEVINFO)

di_lnode_name(3DEVINFO)

di_lnode_next(3DEVINFO)

di_lnode_private_get(3DEVINFO)

di_lnode_private_set(3DEVINFO)

di_minor_devt(3DEVINFO)

di_minor_name(3DEVINFO)

di_minor_next(3DEVINFO)

di_minor_nodetype(3DEVINFO)

di_minor_private_get(3DEVINFO)

di_minor_private_set(3DEVINFO)

di_minor_spectype(3DEVINFO)

di_nodeid(3DEVINFO)

di_node_name(3DEVINFO)

di_node_private_get(3DEVINFO)

di_node_private_set(3DEVINFO)

di_parent_node(3DEVINFO)

di_path_bus_addr(3DEVINFO)

di_path_client_devfs_path(3DEVINFO)

di_path_client_next_path(3DEVINFO)

di_path_client_node(3DEVINFO)

di_path_devfs_path(3DEVINFO)

di_path_instance(3DEVINFO)

di_path_node_name(3DEVINFO)

di_path_phci_next_path(3DEVINFO)

di_path_phci_node(3DEVINFO)

di_path_private_get(3DEVINFO)

di_path_private_set(3DEVINFO)

di_path_prop_bytes(3DEVINFO)

di_path_prop_int64s(3DEVINFO)

di_path_prop_ints(3DEVINFO)

di_path_prop_lookup_bytes(3DEVINFO)

di_path_prop_lookup_int64s(3DEVINFO)

di_path_prop_lookup_ints(3DEVINFO)

di_path_prop_lookup_strings(3DEVINFO)

di_path_prop_name(3DEVINFO)

di_path_prop_next(3DEVINFO)

di_path_prop_strings(3DEVINFO)

di_path_prop_type(3DEVINFO)

di_path_state(3DEVINFO)

di_prom_fini(3DEVINFO)

di_prom_init(3DEVINFO)

di_prom_prop_data(3DEVINFO)

di_prom_prop_lookup_bytes(3DEVINFO)

di_prom_prop_lookup_ints(3DEVINFO)

di_prom_prop_lookup_strings(3DEVINFO)

di_prom_prop_name(3DEVINFO)

di_prom_prop_next(3DEVINFO)

di_prop_bytes(3DEVINFO)

di_prop_devt(3DEVINFO)

di_prop_exists(3DEVINFO)

di_prop_int64(3DEVINFO)

di_prop_ints(3DEVINFO)

di_prop_lookup_bytes(3DEVINFO)

di_prop_lookup_int64(3DEVINFO)

di_prop_lookup_ints(3DEVINFO)

di_prop_lookup_strings(3DEVINFO)

di_prop_name(3DEVINFO)

di_prop_next(3DEVINFO)

di_prop_strings(3DEVINFO)

di_prop_type(3DEVINFO)

di_sibling_node(3DEVINFO)

di_walk_link(3DEVINFO)

di_walk_lnode(3DEVINFO)

di_walk_minor(3DEVINFO)

di_walk_node(3DEVINFO)

ea_alloc(3EXACCT)

ea_attach_to_group(3EXACCT)

ea_attach_to_object(3EXACCT)

ea_close(3EXACCT)

ea_copy_object(3EXACCT)

ea_copy_object_tree(3EXACCT)

ea_error(3EXACCT)

ea_free(3EXACCT)

ea_free_item(3EXACCT)

ea_free_object(3EXACCT)

ea_get_creator(3EXACCT)

ea_get_hostname(3EXACCT)

ea_get_object(3EXACCT)

ea_get_object_tree(3EXACCT)

ea_match_object_catalog(3EXACCT)

ea_next_object(3EXACCT)

ea_open(3EXACCT)

ea_pack_object(3EXACCT)

ea_previous_object(3EXACCT)

ea_set_group(3EXACCT)

ea_set_item(3EXACCT)

ea_strdup(3EXACCT)

ea_strfree(3EXACCT)

ea_unpack_object(3EXACCT)

ea_write_object(3EXACCT)

ecb_crypt(3EXT)

efi_alloc_and_init(3EXT)

efi_alloc_and_read(3EXT)

efi_free(3EXT)

efi_use_whole_disk(3EXT)

efi_write(3EXT)

elf32_checksum(3ELF)

elf32_fsize(3ELF)

elf32_getehdr(3ELF)

elf32_getphdr(3ELF)

elf32_getshdr(3ELF)

elf32_newehdr(3ELF)

elf32_newphdr(3ELF)

elf32_xlatetof(3ELF)

elf32_xlatetom(3ELF)

elf(3ELF)

elf64_checksum(3ELF)

elf64_fsize(3ELF)

elf64_getehdr(3ELF)

elf64_getphdr(3ELF)

elf64_getshdr(3ELF)

elf64_newehdr(3ELF)

elf64_newphdr(3ELF)

elf64_xlatetof(3ELF)

elf64_xlatetom(3ELF)

elf_begin(3ELF)

elf_cntl(3ELF)

elf_end(3ELF)

elf_errmsg(3ELF)

elf_errno(3ELF)

elf_fill(3ELF)

elf_flagdata(3ELF)

elf_flagehdr(3ELF)

elf_flagelf(3ELF)

elf_flagphdr(3ELF)

elf_flagscn(3ELF)

elf_flagshdr(3ELF)

elf_getarhdr(3ELF)

elf_getarsym(3ELF)

elf_getbase(3ELF)

elf_getdata(3ELF)

elf_getident(3ELF)

elf_getphdrnum(3ELF)

elf_getphnum(3ELF)

elf_getscn(3ELF)

elf_getshdrnum(3ELF)

elf_getshdrstrndx(3ELF)

elf_getshnum(3ELF)

elf_getshstrndx(3ELF)

elf_hash(3ELF)

elf_kind(3ELF)

elf_memory(3ELF)

elf_ndxscn(3ELF)

elf_newdata(3ELF)

elf_newscn(3ELF)

elf_next(3ELF)

elf_nextscn(3ELF)

elf_rand(3ELF)

elf_rawdata(3ELF)

elf_rawfile(3ELF)

elf_strptr(3ELF)

elf_update(3ELF)

elf_version(3ELF)

encrypt(3EXT)

FCOE_CreatePort(3FCOE)

FCOE_DeletePort(3FCOE)

FCOE_GetPortList(3FCOE)

fmev_attr_list(3FM)

fmev_class(3FM)

fmev_dup(3FM)

fmev_errno(3FM)

fmev_ev2shdl(3FM)

fmev_hold(3FM)

fmev_hrtime(3FM)

fmev_localtime(3FM)

fmev_rele(3FM)

fmev_shdl_alloc(3FM)

fmev_shdlctl_serialize(3FM)

fmev_shdlctl_sigmask(3FM)

fmev_shdlctl_thrattr(3FM)

fmev_shdlctl_thrcreate(3FM)

fmev_shdlctl_thrsetup(3FM)

fmev_shdl_fini(3FM)

fmev_shdl_free(3FM)

fmev_shdl_getauthority(3FM)

fmev_shdl_init(3FM)

fmev_shdl_nvl2str(3FM)

fmev_shdl_strdup(3FM)

fmev_shdl_strfree(3FM)

fmev_shdl_subscribe(3FM)

fmev_shdl_unsubscribe(3FM)

fmev_shdl_zalloc(3FM)

fmev_strerror(3FM)

fmev_time_nsec(3FM)

fmev_time_sec(3FM)

fmev_timespec(3FM)

fstyp_fini(3FSTYP)

fstyp_get_attr(3FSTYP)

fstyp_ident(3FSTYP)

fstyp_init(3FSTYP)

fstyp_mod_dump(3FSTYP)

fstyp_mod_fini(3FSTYP)

fstyp_mod_get_attr(3FSTYP)

fstyp_mod_ident(3FSTYP)

fstyp_mod_init(3FSTYP)

fstyp_strerror(3FSTYP)

gelf(3ELF)

gelf_checksum(3ELF)

gelf_fsize(3ELF)

gelf_getcap(3ELF)

gelf_getclass(3ELF)

gelf_getdyn(3ELF)

gelf_getehdr(3ELF)

gelf_getmove(3ELF)

gelf_getphdr(3ELF)

gelf_getrel(3ELF)

gelf_getrela(3ELF)

gelf_getshdr(3ELF)

gelf_getsym(3ELF)

gelf_getsyminfo(3ELF)

gelf_getsymshndx(3ELF)

gelf_newehdr(3ELF)

gelf_newphdr(3ELF)

gelf_update_cap(3ELF)

gelf_update_dyn(3ELF)

gelf_update_ehdr(3ELF)

gelf_update_getmove(3ELF)

gelf_update_move(3ELF)

gelf_update_phdr(3ELF)

gelf_update_rel(3ELF)

gelf_update_rela(3ELF)

gelf_update_shdr(3ELF)

gelf_update_sym(3ELF)

gelf_update_syminfo(3ELF)

gelf_update_symshndx(3ELF)

gelf_xlatetof(3ELF)

gelf_xlatetom(3ELF)

generic_events(3CPC)

la_activity(3EXT)

la_amd64_pltenter(3EXT)

la_i86_pltenter(3EXT)

la_objfilter(3EXT)

la_objopen(3EXT)

la_objsearch(3EXT)

la_pltexit(3EXT)

la_pltexit64(3EXT)

la_preinit(3EXT)

la_sparcv8_pltenter(3EXT)

la_sparcv9_pltenter(3EXT)

la_symbind32(3EXT)

la_symbind64(3EXT)

la_version(3EXT)

ld_atexit(3ext)

ld_atexit64(3ext)

ld_file(3ext)

ld_file64(3ext)

ld_input_done(3ext)

ld_input_section(3ext)

ld_input_section64(3ext)

ld_open(3ext)

ld_open64(3ext)

ld_section(3ext)

ld_section64(3ext)

ld_start(3ext)

ld_start64(3ext)

ld_support(3ext)

ld_version(3ext)

LIST_EMPTY(3EXT)

LIST_ENTRY(3EXT)

LIST_FIRST(3EXT)

LIST_FOREACH(3EXT)

LIST_HEAD(3EXT)

LIST_HEAD_INITIALIZER(3EXT)

LIST_INIT(3EXT)

LIST_INSERT_AFTER(3EXT)

LIST_INSERT_BEFORE(3EXT)

LIST_INSERT_HEAD(3EXT)

LIST_NEXT(3EXT)

LIST_REMOVE(3EXT)

md4(3EXT)

MD4Final(3EXT)

MD4Init(3EXT)

MD4Update(3EXT)

md5(3EXT)

md5_calc(3EXT)

MD5Final(3EXT)

MD5Init(3EXT)

MD5Update(3EXT)

nlist(3ELF)

NOTE(3EXT)

_NOTE(3EXT)

pctx_capture(3CPC)

pctx_create(3CPC)

pctx_release(3CPC)

pctx_run(3CPC)

pctx_set_events(3CPC)

queue(3EXT)

rd_delete(3EXT)

rd_errstr(3EXT)

rd_event_addr(3EXT)

rd_event_enable(3EXT)

rd_event_getmsg(3EXT)

rd_init(3EXT)

rd_loadobj_iter(3EXT)

rd_log(3EXT)

rd_new(3EXT)

rd_objpad_enable(3EXT)

rd_plt_resolution(3EXT)

rd_reset(3EXT)

read_vtoc(3EXT)

rtld_audit(3EXT)

rtld_db(3EXT)

run_crypt(3EXT)

run_setkey(3EXT)

sendfile(3EXT)

sendfilev(3EXT)

setkey(3EXT)

sha1(3EXT)

SHA1Final(3EXT)

SHA1Init(3EXT)

SHA1Update(3EXT)

SHA224Final(3EXT)

SHA224Init(3EXT)

SHA224Update(3EXT)

sha2(3EXT)

SHA256Final(3EXT)

SHA256Init(3EXT)

SHA256Update(3EXT)

SHA2Final(3EXT)

SHA2Init(3EXT)

SHA2Update(3EXT)

SHA384Final(3EXT)

SHA384Init(3EXT)

SHA384Update(3EXT)

SHA512Final(3EXT)

SHA512Init(3EXT)

SHA512Update(3EXT)

SIMPLEQ_EMPTY(3EXT)

SIMPLEQ_ENTRY(3EXT)

SIMPLEQ_FIRST(3EXT)

SIMPLEQ_FOREACH(3EXT)

SIMPLEQ_HEAD(3EXT)

SIMPLEQ_HEAD_INITIALIZER(3EXT)

SIMPLEQ_INIT(3EXT)

SIMPLEQ_INSERT_AFTER(3EXT)

SIMPLEQ_INSERT_HEAD(3EXT)

SIMPLEQ_INSERT_TAIL(3EXT)

SIMPLEQ_NEXT(3EXT)

SIMPLEQ_REMOVE(3EXT)

SIMPLEQ_REMOVE_HEAD(3EXT)

SLIST_EMPTY(3EXT)

SLIST_ENTRY(3EXT)

SLIST_FIRST(3EXT)

SLIST_FOREACH(3EXT)

SLIST_HEAD(3EXT)

SLIST_HEAD_INITIALIZER(3EXT)

SLIST_INIT(3EXT)

SLIST_INSERT_AFTER(3EXT)

SLIST_INSERT_HEAD(3EXT)

SLIST_NEXT(3EXT)

SLIST_REMOVE(3EXT)

SLIST_REMOVE_HEAD(3EXT)

STAILQ_CONCAT(3EXT)

STAILQ_EMPTY(3EXT)

STAILQ_ENTRY(3EXT)

STAILQ_FIRST(3EXT)

STAILQ_FOREACH(3EXT)

STAILQ_HEAD(3EXT)

STAILQ_HEAD_INITIALIZER(3EXT)

STAILQ_INIT(3EXT)

STAILQ_INSERT_AFTER(3EXT)

STAILQ_INSERT_HEAD(3EXT)

STAILQ_INSERT_TAIL(3EXT)

STAILQ_NEXT(3EXT)

STAILQ_REMOVE(3EXT)

STAILQ_REMOVE_HEAD(3EXT)

stdarg(3EXT)

SUNW_C_GetMechSession(3EXT)

SUNW_C_KeyToObject(3EXT)

TAILQ_CONCAT(3EXT)

TAILQ_EMPTY(3EXT)

TAILQ_ENTRY(3EXT)

TAILQ_FIRST(3EXT)

TAILQ_FOREACH(3EXT)

TAILQ_FOREACH_REVERSE(3EXT)

TAILQ_HEAD(3EXT)

TAILQ_HEAD_INITIALIZER(3EXT)

TAILQ_INIT(3EXT)

TAILQ_INSERT_AFTER(3EXT)

TAILQ_INSERT_BEFORE(3EXT)

TAILQ_INSERT_HEAD(3EXT)

TAILQ_INSERT_TAIL(3EXT)

TAILQ_LAST(3EXT)

TAILQ_NEXT(3EXT)

TAILQ_PREV(3EXT)

TAILQ_REMOVE(3EXT)

tsalarm_get(3EXT)

tsalarm_set(3EXT)

v12n(3EXT)

v12n_capabilities(3EXT)

v12n_chassis_serialno(3EXT)

v12n_ctrl_domain(3EXT)

v12n_domain_name(3EXT)

v12n_domain_roles(3EXT)

v12n_domain_uuid(3EXT)

varargs(3EXT)

write_vtoc(3EXT)

queue

, SLIST_HEAD

, SLIST_HEAD_INITIALIZER

, SLIST_ENTRY

, SLIST_INIT

, SLIST_INSERT_AFTER

, SLIST_INSERT_HEAD

, SLIST_REMOVE_HEAD

, SLIST_REMOVE

, SLIST_FOREACH

, SLIST_EMPTY

, SLIST_FIRST

, SLIST_NEXT

, SIMPLEQ_HEAD

, SIMPLEQ_HEAD_INITIALIZER

, SIMPLEQ_ENTRY

, SIMPLEQ_INIT

, SIMPLEQ_INSERT_HEAD

, SIMPLEQ_INSERT_TAIL

, SIMPLEQ_INSERT_AFTER

, SIMPLEQ_REMOVE_HEAD

, SIMPLEQ_REMOVE

, SIMPLEQ_FOREACH

, SIMPLEQ_EMPTY

, SIMPLEQ_FIRST

, SIMPLEQ_NEXT

, STAILQ_HEAD

, STAILQ_HEAD_INITIALIZER

, STAILQ_ENTRY

, STAILQ_INIT

, STAILQ_INSERT_HEAD

, STAILQ_INSERT_TAIL

, STAILQ_INSERT_AFTER

, STAILQ_REMOVE_HEAD

, STAILQ_REMOVE

, STAILQ_FOREACH

, STAILQ_EMPTY

, STAILQ_FIRST

, STAILQ_NEXT

, STAILQ_CONCAT

, LIST_HEAD

, LIST_HEAD_INITIALIZER

, LIST_ENTRY

, LIST_INIT

, LIST_INSERT_AFTER

, LIST_INSERT_BEFORE

, LIST_INSERT_HEAD

, LIST_REMOVE

, LIST_FOREACH

, LIST_EMPTY

, LIST_FIRST

, LIST_NEXT

, TAILQ_HEAD

, TAILQ_HEAD_INITIALIZER

, TAILQ_ENTRY

, TAILQ_INIT

, TAILQ_INSERT_HEAD

, TAILQ_INSERT_TAIL

, TAILQ_INSERT_AFTER

, TAILQ_INSERT_BEFORE

, TAILQ_REMOVE

, TAILQ_FOREACH

, TAILQ_FOREACH_REVERSE

, TAILQ_EMPTY

, TAILQ_FIRST

, TAILQ_NEXT

, TAILQ_LAST

, TAILQ_PREV

, TAILQ_CONCAT

, CIRCLEQ_HEAD

, CIRCLEQ_HEAD_INITIALIZER

, CIRCLEQ_ENTRY

, CIRCLEQ_INIT

, CIRCLEQ_INSERT_AFTER

, CIRCLEQ_INSERT_BEFORE

, CIRCLEQ_INSERT_HEAD

, CIRCLEQ_INSERT_TAIL

, CIRCLEQ_REMOVE

, CIRCLEQ_FOREACH

, CIRCLEQ_FOREACH_REVERSE

, CIRCLEQ_EMPTY

, CIRCLEQ_FIRST

, CIRCLEQ_LAST

, CIRCLEQ_NEXT

, CIRCLEQ_PREV

, CIRCLEQ_LOOP_NEXT

, CIRCLEQ_LOOP_PREV

- implementations of singly-linked lists, simple queues, lists, tail queues, and circular queues

Synopsis

#include <sys/queue.h>

SLIST_HEAD(HEADNAME, TYPE);
SLIST_HEAD_INITIALIZER(head);
SLIST_ENTRY(TYPE);
SLIST_INIT(SLIST_HEAD *head)
SLIST_INSERT_AFTER(TYPE *listelm, TYPE *elm, SLIST_ENTRY NAME);
SLIST_INSERT_HEAD(SLIST_HEAD *head, TYPE *elm, SLIST_ENTRY NAME)
SLIST_REMOVE_HEAD(SLIST_HEAD *head, SLIST_ENTRY NAME);
SLIST_REMOVE(SLIST_HEAD *head, TYPE *elm, TYPE, SLIST_ENTRY NAME);
SLIST_FOREACH(TYPE *var, SLIST_HEAD *head, SLIST_ENTRY NAME);
int SLIST_EMPTY(SLIST_HEAD *head);
TYPE *SLIST_FIRST(SLIST_HEAD *head);
TYPE *SLIST_NEXT(TYPE *elm, SLIST_ENTRY NAME);
SIMPLEQ_HEAD(HEADNAME, TYPE);
SIMPLEQ_HEAD_INITIALIZER(head);
SIMPLEQ_ENTRY(TYPE);
SIMPLEQ_INIT(SIMPLEQ_HEAD *head);
SIMPLEQ_INSERT_HEAD(SIMPLEQ_HEAD *head, TYPE *elm, SIMPLEQ_ENTRY NAME);
SIMPLEQ_INSERT_TAIL(SIMPLEQ_HEAD *head, TYPE *elm, SIMPLEQ_ENTRY NAME);
SIMPLEQ_INSERT_AFTER(SIMPLEQ_HEAD *head, TYPE *listelm, TYPE *elm,
     SIMPLEQ_ENTRY NAME);
SIMPLEQ_REMOVE_HEAD(SIMPLEQ_HEAD *head, SIMPLEQ_ENTRY NAME);
SIMPLEQ_REMOVE(SIMPLEQ_HEAD *head, TYPE *elm, TYPE, SIMPLEQ_ENTRY NAME);
SIMPLEQ_FOREACH(TYPE *var, SIMPLEQ_HEAD *head, SIMPLEQ_ENTRY NAME);
int SIMPLEQ_EMPTY(SIMPLEQ_HEAD *head)
TYPE *SIMPLEQ_FIRST(SIMPLEQ_HEAD *head);
TYPE *SIMPLEQ_NEXT(TYPE *elm, SIMPLEQ_ENTRY NAME);
STAILQ_HEAD(HEADNAME, TYPE);
STAILQ_HEAD_INITIALIZER(head);
STAILQ_ENTRY(TYPE);
STAILQ_INIT(STAILQ_HEAD *head);
STAILQ_INSERT_HEAD(STAILQ_HEAD *head, TYPE *elm, STAILQ_ENTRY NAME);
STAILQ_INSERT_TAIL(STAILQ_HEAD *head, TYPE *elm, STAILQ_ENTRY NAME);
STAILQ_INSERT_AFTER(STAILQ_HEAD *head, TYPE *listelm, TYPE *elm,
     STAILQ_ENTRY NAME);
STAILQ_REMOVE_HEAD(STAILQ_HEAD *head, STAILQ_ENTRY NAME);
STAILQ_REMOVE(STAILQ_HEAD *head, TYPE *elm, TYPE, STAILQ_ENTRY NAME);
STAILQ_FOREACH(TYPE *var, STAILQ_HEAD *head, STAILQ_ENTRY NAME);
int STAILQ_EMPTY(STAILQ_HEAD *head);
TYPE *STAILQ_FIRST(STAILQ_HEAD *head);
TYPE *STAILQ_NEXT(TYPE *elm, STAILQ_ENTRY NAME);
STAILQ_CONCAT(STAILQ_HEAD *head1, STAILQ_HEAD *head2);
LIST_HEAD(HEADNAME, TYPE);
LIST_HEAD_INITIALIZER(head);
LIST_ENTRY(TYPE);
LIST_INIT(LIST_HEAD *head);
LIST_INSERT_AFTER(TYPE *listelm, TYPE *elm, LIST_ENTRY NAME);
LIST_INSERT_BEFORE(TYPE *listelm, TYPE *elm, LIST_ENTRY NAME);
LIST_INSERT_HEAD(LIST_HEAD *head, TYPE *elm, LIST_ENTRY NAME);
LIST_REMOVE(TYPE *elm, LIST_ENTRY NAME);
LIST_FOREACH(TYPE *var, LIST_HEAD *head, LIST_ENTRY NAME);
int LIST_EMPTY(LIST_HEAD *head);
TYPE *LIST_FIRST(LIST_HEAD *head);
TYPE *LIST_NEXT(TYPE *elm, LIST_ENTRY NAME);
TAILQ_HEAD(HEADNAME, TYPE);
TAILQ_HEAD_INITIALIZER(head);
TAILQ_ENTRY(TYPE);
TAILQ_INIT(TAILQ_HEAD *head);
TAILQ_INSERT_HEAD(TAILQ_HEAD *head, TYPE *elm, TAILQ_ENTRY NAME);
TAILQ_INSERT_TAIL(TAILQ_HEAD *head, TYPE *elm, TAILQ_ENTRY NAME)
TAILQ_INSERT_AFTER(TAILQ_HEAD *head, TYPE *listelm, TYPE *elm,
     TAILQ_ENTRY NAME);
TAILQ_INSERT_BEFORE(TYPE *listelm, TYPE *elm, TAILQ_ENTRY NAME);
TAILQ_REMOVE(TAILQ_HEAD *head, TYPE *elm, TAILQ_ENTRY NAME);
TAILQ_FOREACH(TYPE *var, TAILQ_HEAD *head, TAILQ_ENTRY NAME);
TAILQ_FOREACH_REVERSE(TYPE *var, TAILQ_HEAD *head, HEADNAME,
     TAILQ_ENTRY NAME);
int TAILQ_EMPTY(TAILQ_HEAD *head);
TYPE *TAILQ_FIRST(TAILQ_HEAD *head);
TYPE *TAILQ_NEXT(TYPE *elm, TAILQ_ENTRY NAME);
TYPE *TAILQ_LAST(TAILQ_HEAD *head, HEADNAME);
TYPE *TAILQ_PREV(TYPE *elm, HEADNAME, TAILQ_ENTRY NAME);
TAILQ_CONCAT(TAILQ_HEAD *head1, TAILQ_HEAD *head2, TAILQ_ENTRY NAME);
CIRCLEQ_HEAD(HEADNAME, TYPE);
CIRCLEQ_HEAD_INITIALIZER(head);
CIRCLEQ_ENTRY(TYPE);
CIRCLEQ_INIT(CIRCLEQ_HEAD *head);
CIRCLEQ_INSERT_AFTER(CIRCLEQ_HEAD *head, TYPE *listelm, TYPE *elm,
     CIRCLEQ_ENTRY NAME);
CIRCLEQ_INSERT_BEFORE(CIRCLEQ_HEAD *head, TYPE *listelm, TYPE *elm,
     CIRCLEQ_ENTRY NAME);
CIRCLEQ_INSERT_HEAD(CIRCLEQ_HEAD *head, TYPE *elm, CIRCLEQ_ENTRY NAME);
CIRCLEQ_INSERT_TAIL(CIRCLEQ_HEAD *head, TYPE *elm, CIRCLEQ_ENTRY NAME);
CIRCLEQ_REMOVE(CIRCLEQ_HEAD *head, TYPE *elm, CIRCLEQ_ENTRY NAME);
CIRCLEQ_FOREACH(TYPE *var, CIRCLEQ_HEAD *head, CIRCLEQ_ENTRY NAME);
CIRCLEQ_FOREACH_REVERSE(TYPE *var, CIRCLEQ_HEAD *head,
     CIRCLEQ_ENTRY NAME);
int CIRCLEQ_EMPTY(CIRCLEQ_HEAD *head);
TYPE *CIRCLEQ_FIRST(CIRCLEQ_HEAD *head);
TYPE *CIRCLEQ_LAST(CIRCLEQ_HEAD *head);
TYPE *CIRCLEQ_NEXT(TYPE *elm, CIRCLEQ_ENTRY NAME);
TYPE *CIRCLEQ_PREV(TYPE *elm, CIRCLEQ_ENTRY NAME);
TYPE *CIRCLEQ_LOOP_NEXT(CIRCLEQ_HEAD *head, TYPE *elm, CIRCLEQ_ENTRY NAME);
TYPE *CIRCLEQ_LOOP_PREV(CIRCLEQ_HEAD *head, TYPE *elm, CIRCLEQ_ENTRY NAME);

Description

These macros define and operate on five types of data structures: singly- linked lists, simple queues, lists, tail queues, and circular queues. All five structures support the following functionality:

  1. Insertion of a new entry at the head of the list.

  2. Insertion of a new entry before or after any element in the list.

  3. Removal of any entry in the list.

  4. Forward traversal through the list.

Singly-linked lists are the simplest of the five data structures and support only the above functionality. Singly-linked lists are ideal for applications with large datasets and few or no removals, or for implementing a LIFO queue.

  1. Entries can be added at the end of a list.

  2. They may be concatenated.

However:

  1. Entries may not be added before any element in the list.

  2. All list insertions and removals must specify the head of the list.

  3. Each head entry requires two pointers rather than one.

Simple queues are ideal for applications with large datasets and few or no removals, or for implementing a FIFO queue.

All doubly linked types of data structures (lists, tail queues, and circle queues) additionally allow:

  1. Insertion of a new entry before any element in the list.

  2. O(1) removal of any entry in the list.

However:

  1. Each element requires two pointers rather than one.

  2. Code size and execution time of operations (except for removal) is about twice that of the singly-linked data structures

Linked lists are the simplest of the doubly linked data structures and support only the above functionality over singly-linked lists.

Tail queues add the following functionality:

  1. Entries can be added at the end of a list.

  2. They may be concatenated.

However:

  1. All list insertions and removals, except insertion before another element, must specify the head of the list.

  2. Each head entry requires two pointers rather than one.

  3. Code size is about 15% greater and operations run about 20% slower than lists.

Circular queues add the following functionality:

  1. Entries can be added at the end of a list.

  2. They may be traversed backwards, from tail to head.

However:

  1. All list insertions and removals must specify the head of the list.

  2. Each head entry requires two pointers rather than one.

  3. The termination condition for traversal is more complex.

  4. Code size is about 40% greater and operations run about 45% slower than lists.

In the macro definitions, TYPE is the name of a user defined structure, that must contain a field of type LIST_ENTRY, SIMPLEQ_ENTRY, SLIST_ENTRY, TAILQ_ENTRY, or CIRCLEQ_ENTRY, named NAME. The argument HEADNAME is the name of a user defined structure that must be declared using the macros LIST_HEAD(), SIMPLEQ_HEAD(), SLIST_HEAD(), TAILQ_HEAD(), or CIRCLEQ_HEAD(). See the examples below for further explanation of how these macros are used.

Summary of Operations

The following table summarizes the supported macros for each type of data structure.

+-----------------+-------+------+---------+--------+-------+---------+
|                 | SLIST | LIST | SIMPLEQ | STAILQ | TAILQ | CIRCLEQ |
+-----------------+-------+------+---------+--------+-------+---------+
|_EMPTY           |   +   |  +   |    +    |   +    |   +   |    +    |
|_FIRST           |   +   |  +   |    +    |   +    |   +   |    +    |
|_FOREACH         |   +   |  +   |    +    |   +    |   +   |    +    |
|_FOREACH_REVERSE |   -   |  -   |    -    |   -    |   +   |    +    |
|_INSERT_AFTER    |   +   |  +   |    +    |   +    |   +   |    +    |
|_INSERT_BEFORE   |   -   |  +   |    -    |   -    |   +   |    +    |
|_INSERT_HEAD     |   +   |  +   |    +    |   +    |   +   |    +    |
|_INSERT_TAIL     |   -   |  -   |    +    |   +    |   +   |    +    |
|_LAST            |   -   |  -   |    -    |   -    |   +   |    +    |
|_LOOP_NEXT       |   -   |  -   |    -    |   -    |   -   |    +    |
|_LOOP_PREV       |   -   |  -   |    -    |   -    |   -   |    +    |
|_NEXT            |   +   |  +   |    +    |   +    |   +   |    +    |
|_PREV            |   -   |  -   |    -    |   -    |   +   |    +    |
|_REMOVE          |   +   |  +   |    +    |   +    |   +   |    +    |
|_REMOVE_HEAD     |   +   |  -   |    +    |   +    |   -   |    -    |
|_CONCAT          |   -   |  -   |    -    |   +    |   +   |    -    |
+-----------------+-------+------+---------+--------+-------+---------+

Singly-linked Lists

A singly-linked list is headed by a structure defined by the SLIST_HEAD() macro. This structure contains a single pointer to the first element on the list. The elements are singly linked for minimum space and pointer manipulation overhead at the expense of O(n) removal for arbitrary elements. New elements can be added to the list after an existing element or at the head of the list. An SLIST_HEAD structure is declared as follows:

SLIST_HEAD(HEADNAME, TYPE) head;

where HEADNAME is the name of the structure to be defined, and TYPE is the type of the elements to be linked into the list. A pointer to the head of the list can later be declared as:

struct HEADNAME *headp;

The names head and headp are user selectable.

The macro SLIST_HEAD_INITIALIZER() evaluates to an initializer for the list head

The macro SLIST_EMPTY() evaluates to true if there are no elements in the list.

The macro SLIST_ENTRY() declares a structure that connects the elements in the list.

The macro SLIST_FIRST() returns the first element in the list or NULL if the list is empty.

The macro SLIST_FOREACH() traverses the list referenced by head in the forward direction, assigning each element in turn to var.

The macro SLIST_INIT() initializes the list referenced by head.

The macro SLIST_INSERT_HEAD() inserts the new element elm at the head of the list.

The macro SLIST_INSERT_AFTER() inserts the new element elm after the element listelm.

The macro SLIST_NEXT() returns the next element in the list.

The macro SLIST_REMOVE() removes the element elm from the list.

The macro SLIST_REMOVE_HEAD() removes the first element from the head of the list. For optimum efficiency, elements being removed from the head of the list should explicitly use this macro instead of the generic SLIST_REMOVE() macro.

Singly-linked List Example

SLIST_HEAD(slisthead, entry) head =
    SLIST_HEAD_INITIALIZER(head);
struct slisthead *headp;                /* Singly-linked List head. */
struct entry {
        ...
        SLIST_ENTRY(entry) entries;     /* Singly-linked List. */
        ...
} *n1, *n2, *n3, *np;

SLIST_INIT(&head);                      /* Initialize the list. */

n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
SLIST_INSERT_HEAD(&head, n1, entries);

n2 = malloc(sizeof(struct entry));      /* Insert after. */
SLIST_INSERT_AFTER(n1, n2, entries);

SLIST_REMOVE(&head, n2, entry, entries);/* Deletion. */
free(n2);

n3 = SLIST_FIRST(&head);
SLIST_REMOVE_HEAD(&head, entries);      /* Deletion from the head. */
free(n3);
                                        /* Forward traversal. */
SLIST_FOREACH(np, &head, entries)
        np-> ...

while (!SLIST_EMPTY(&head)) {           /* List Deletion. */
        n1 = SLIST_FIRST(&head);
        SLIST_REMOVE_HEAD(&head, entries);
        free(n1);
}

Simple Queues

A simple queue is headed by a structure defined by the SIMPLEQ_HEAD() macro. This structure contains a pair of pointers, one to the first element in the simple queue and the other to the last element in the simple queue. The elements are singly linked for minimum space and pointer manipulation overhead at the expense of O(n) removal for arbitrary elements. New elements can be added to the queue after an existing element, at the head of the queue, or at the end of the queue. A SIMPLEQ_HEAD structure is declared as follows:

SIMPLEQ_HEAD(HEADNAME, TYPE) head;

where HEADNAME is the name of the structure to be defined, and TYPE is the type of the elements to be linked into the simple queue. A pointer to the head of the simple queue can later be declared as:

struct HEADNAME *headp;

The names head and headp are user selectable.

The macro SIMPLEQ_ENTRY() declares a structure that connects the elements in the simple queue.

The macro SIMPLEQ_HEAD_INITIALIZER() provides a value which can be used to initialize a simple queue head at compile time, and is used at the point that the simple queue head variable is declared, like:

struct HEADNAME head = SIMPLEQ_HEAD_INITIALIZER(head);

The macro SIMPLEQ_INIT() initializes the simple queue referenced by head.

The macro SIMPLEQ_INSERT_HEAD() inserts the new element elm at the head of the simple queue.

The macro SIMPLEQ_INSERT_TAIL() inserts the new element elm at the end of the simple queue.

The macro SIMPLEQ_INSERT_AFTER() inserts the new element elm after the element listelm.

The macro SIMPLEQ_REMOVE() removes elm from the simple queue.

The macro SIMPLEQ_REMOVE_HEAD() removes the first element from the head of the simple queue. For optimum efficiency, elements being removed from the head of the queue should explicitly use this macro instead of the generic SIMPLQ_REMOVE() macro.

The macro SIMPLEQ_EMPTY() return true if the simple queue head has no elements.

The macro SIMPLEQ_FIRST() returns the first element of the simple queue head.

The macro SIMPLEQ_FOREACH() traverses the tail queue referenced by head in the forward direction, assigning each element in turn to var.

The macro SIMPLEQ_NEXT() returns the element after the element elm.

The macros prefixed with “STAILQ_” (STAILQ_HEAD(), STAILQ_HEAD_INITIALIZER(), STAILQ_ENTRY(), STAILQ_INIT(), STAILQ_INSERT_HEAD(), STAILQ_INSERT_TAIL(), STAILQ_INSERT_AFTER(), STAILQ_REMOVE_HEAD(), STAILQ_REMOVE(), STAILQ_FOREACH(), STAILQ_EMPTY(), STAILQ_FIRST(), and STAILQ_NEXT()) are functionally identical to these simple queue functions, and are provided for compatibility with FreeBSD.

Simple Queue Example

SIMPLEQ_HEAD(simplehead, entry) head;
struct simplehead *headp;               /* Simple queue head. */
struct entry {
        ...
        SIMPLEQ_ENTRY(entry) entries;   /* Simple queue. */
        ...
} *n1, *n2, *np;

SIMPLEQ_INIT(&head);                    /* Initialize the queue. */

n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
SIMPLEQ_INSERT_HEAD(&head, n1, entries);

n1 = malloc(sizeof(struct entry));      /* Insert at the tail. */
SIMPLEQ_INSERT_TAIL(&head, n1, entries);

n2 = malloc(sizeof(struct entry));      /* Insert after. */
SIMPLEQ_INSERT_AFTER(&head, n1, n2, entries);
                                        /* Forward traversal. */
SIMPLEQ_FOREACH(np, &head, entries)
        np-> ...
                                        /* Delete. */
while (SIMPLEQ_FIRST(&head) != NULL)
        SIMPLEQ_REMOVE_HEAD(&head, entries);
if (SIMPLEQ_EMPTY(&head))               /* Test for emptiness. */
        printf("nothing to do\n");

Lists

A list is headed by a structure defined by the LIST_HEAD() macro. This structure contains a single pointer to the first element on the list. The elements are doubly linked so that an arbitrary element can be removed without traversing the list. New elements can be added to the list after an existing element, before an existing element, or at the head of the list. A LIST_HEAD structure is declared as follows:

LIST_HEAD(HEADNAME, TYPE) head;

where HEADNAME is the name of the structure to be defined, and TYPE is the type of the elements to be linked into the list. A pointer to the head of the list can later be declared as:

struct HEADNAME *headp;

The names head and headp are user selectable.

The macro LIST_ENTRY() declares a structure that connects the elements in the list.

The macro LIST_HEAD_INITIALIZER() provides a value which can be used to initialize a list head at compile time, and is used at the point that the list head variable is declared, like:

struct HEADNAME head = LIST_HEAD_INITIALIZER(head);

The macro LIST_INIT() initializes the list referenced by head.

The macro LIST_INSERT_HEAD() inserts the new element elm at the head of the list.

The macro LIST_INSERT_AFTER() inserts the new element elm after the element listelm.

The macro LIST_INSERT_BEFORE() inserts the new element elm before the element listelm.

The macro LIST_REMOVE() removes the element elm from the list.

The macro LIST_EMPTY() returns true if the list head has no elements.

The macro LIST_FIRST() returns the first element of the list head.

The macro LIST_FOREACH() traverses the list referenced by head in the forward direction, assigning each element in turn to var.

The macro LIST_NEXT() returns the element after the element elm.

List Example

LIST_HEAD(listhead, entry) head;
struct listhead *headp;         /* List head. */
struct entry {
        ...
        LIST_ENTRY(entry) entries;      /* List. */
        ...
} *n1, *n2, *np;

LIST_INIT(&head);                       /* Initialize the list. */

n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
LIST_INSERT_HEAD(&head, n1, entries);

n2 = malloc(sizeof(struct entry));      /* Insert after. */
LIST_INSERT_AFTER(n1, n2, entries);

n2 = malloc(sizeof(struct entry));      /* Insert before. */
LIST_INSERT_BEFORE(n1, n2, entries);
                                        /* Forward traversal. */
LIST_FOREACH(np, &head, entries)
        np-> ...
                                        /* Delete. */
while (LIST_FIRST(&head) != NULL)
        LIST_REMOVE(LIST_FIRST(&head), entries);
if (LIST_EMPTY(&head))                  /* Test for emptiness. */
        printf("nothing to do\n");

Tail Queues

A tail queue is headed by a structure defined by the TAILQ_HEAD() macro. This structure contains a pair of pointers, one to the first element in the tail queue and the other to the last element in the tail queue. The elements are doubly linked so that an arbitrary element can be removed without traversing the tail queue. New elements can be added to the queue after an existing element, before an existing element, at the head of the queue, or at the end the queue. A TAILQ_HEAD structure is declared as follows:

TAILQ_HEAD(HEADNAME, TYPE) head;

where HEADNAME is the name of the structure to be defined, and TYPE is the type of the elements to be linked into the tail queue. A pointer to the head of the tail queue can later be declared as:

struct HEADNAME *headp;

The names head and headp are user selectable.

The macro TAILQ_ENTRY() declares a structure that connects the elements in the tail queue.

The macro TAILQ_HEAD_INITIALIZER() provides a value which can be used to initialize a tail queue head at compile time, and is used at the point that the tail queue head variable is declared, like:

struct HEADNAME head = TAILQ_HEAD_INITIALIZER(head);

The macro TAILQ_INIT() initializes the tail queue referenced by head.

The macro TAILQ_INSERT_HEAD() inserts the new element elm at the head of the tail queue.

The macro TAILQ_INSERT_TAIL() inserts the new element elm at the end of the tail queue.

The macro TAILQ_INSERT_AFTER() inserts the new element elm after the element listelm.

The macro TAILQ_INSERT_BEFORE() inserts the new element elm before the element listelm.

The macro TAILQ_REMOVE() removes the element elm from the tail queue.

The macro TAILQ_EMPTY() return true if the tail queue head has no elements.

The macro TAILQ_FIRST() returns the first element of the tail queue head.

The macro TAILQ_FOREACH() traverses the tail queue referenced by head in the forward direction, assigning each element in turn to var.

The macro TAILQ_FOREACH_REVERSE() traverses the tail queue referenced by head in the reverse direction, assigning each element in turn to var.

The macro TAILQ_NEXT() returns the element after the element elm.

The macro TAILQ_CONCAT() concatenates the tail queue headed by head2 onto the end of the one headed by head1 removing all entries from the former.

Tail Queue Example

TAILQ_HEAD(tailhead, entry) head;
struct tailhead *headp;         /* Tail queue head. */
struct entry {
        ...
        TAILQ_ENTRY(entry) entries;     /* Tail queue. */
        ...
} *n1, *n2, *np;

TAILQ_INIT(&head);                      /* Initialize the queue. */

n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
TAILQ_INSERT_HEAD(&head, n1, entries);

n1 = malloc(sizeof(struct entry));      /* Insert at the tail. */
TAILQ_INSERT_TAIL(&head, n1, entries);

n2 = malloc(sizeof(struct entry));      /* Insert after. */
TAILQ_INSERT_AFTER(&head, n1, n2, entries);

n2 = malloc(sizeof(struct entry));      /* Insert before. */
TAILQ_INSERT_BEFORE(n1, n2, entries);
                                        /* Forward traversal. */
TAILQ_FOREACH(np, &head, entries)
        np-> ...
                                        /* Reverse traversal. */
TAILQ_FOREACH_REVERSE(np, &head, tailhead, entries)
        np-> ...
                                        /* Delete. */
while (TAILQ_FIRST(&head) != NULL)
        TAILQ_REMOVE(&head, TAILQ_FIRST(&head), entries);
if (TAILQ_EMPTY(&head))                 /* Test for emptiness. */
        printf("nothing to do\n");

Circular Queues

A circular queue is headed by a structure defined by the CIRCLEQ_HEAD() macro. This structure contains a pair of pointers, one to the first element in the circular queue and the other to the last element in the circular queue. The elements are doubly linked so that an arbitrary element can be removed without traversing the queue. New elements can be added to the queue after an existing element, before an existing element, at the head of the queue, or at the end of the queue. A CIRCLEQ_HEAD structure is declared as follows:

CIRCLEQ_HEAD(HEADNAME, TYPE) head;

where HEADNAME is the name of the structure to be defined, and TYPE is the type of the elements to be linked into the circular queue. A pointer to the head of the circular queue can later be declared as:

struct HEADNAME *headp;

The names head and headp are user selectable.

The macro CIRCLEQ_ENTRY() declares a structure that connects the elements in the circular queue.

The macro CIRCLEQ_HEAD_INITIALIZER() provides a value which can be used to initialize a circular queue head at compile time, and is used at the point that the circular queue head variable is declared, like:

struct HEADNAME() head() = CIRCLEQ_HEAD_INITIALIZER(head());

The macro CIRCLEQ_INIT() initializes the circular queue referenced by head.

The macro CIRCLEQ_INSERT_HEAD() inserts the new element elm at the head of the circular queue.

The macro CIRCLEQ_INSERT_TAIL() inserts the new element elm at the end of the circular queue.

The macro CIRCLEQ_INSERT_AFTER() inserts the new element elm after the element listelm.

The macro CIRCLEQ_INSERT_BEFORE() inserts the new element elm before the element listelm.

The macro CIRCLEQ_REMOVE() removes the element elm from the circular queue.

The macro CIRCLEQ_EMPTY() return true if the circular queue head has no elements.

The macro CIRCLEQ_FIRST() returns the first element of the circular queue head.

The macro CIRCLEQ_FOREACH() traverses the circle queue referenced by head in the forward direction, assigning each element in turn to var. Each element is assigned exactly once.

The macro CIRCLEQ_FOREACH_REVERSE() traverses the circle queue referenced by head in the reverse direction, assigning each element in turn to var. Each element is assigned exactly once.

The macro CIRCLEQ_LAST() returns the last element of the circular queue head.

The macro CIRCLEQ_NEXT() returns the element after the element elm.

The macro CIRCLEQ_PREV() returns the element before the element elm.

The macro CIRCLEQ_LOOP_NEXT() returns the element after the element elm. If elm was the last element in the queue, the first element is returned.

The macro CIRCLEQ_LOOP_PREV() returns the element before the element elm. If elm was the first element in the queue, the last element is returned.

Circular Queue Example

CIRCLEQ_HEAD(circleq, entry) head;
struct circleq *headp;                  /* Circular queue head. */
struct entry {
        ...
        CIRCLEQ_ENTRY(entry) entries;   /* Circular queue. */
        ...
} *n1, *n2, *np;

CIRCLEQ_INIT(&head);                    /* Initialize circular queue. */


n1 = malloc(sizeof(struct entry));      /* Insert at the head. */
CIRCLEQ_INSERT_HEAD(&head, n1, entries);

n1 = malloc(sizeof(struct entry));      /* Insert at the tail. */
CIRCLEQ_INSERT_TAIL(&head, n1, entries);

n2 = malloc(sizeof(struct entry));      /* Insert after. */
CIRCLEQ_INSERT_AFTER(&head, n1, n2, entries);

n2 = malloc(sizeof(struct entry));      /* Insert before. */
CIRCLEQ_INSERT_BEFORE(&head, n1, n2, entries);
                                        /* Forward traversal. */
CIRCLEQ_FOREACH(np, &head, entries)
        np-> ...
                                        /* Reverse traversal. */
CIRCLEQ_FOREACH_REVERSE(np, &head, entries)
        np-> ...
                                        /* Delete. */
while (CIRCLEQ_FIRST(&head) != (void *)&head)
        CIRCLEQ_REMOVE(&head, CIRCLEQ_FIRST(&head), entries);
if (CIRCLEQ_EMPTY(&head))               /* Test for emptiness. */
        printf("nothing to do\n");

Attributes

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

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed

See Also

attributes(5), queue(9F)

Notes

Some of these macros or functions perform no error checking, and invalid usage leads to undefined behavior. In the case of macros or functions that expect their arguments to be elements that are present in the list or queue, passing an element that is not present is invalid.

The queue functions first appeared in 4.4BSD. The SIMPLEQ functions first appeared in NetBSD 1.2. The SLIST and STAILQ functions first appeared in FreeBSD 2.1.5. The CIRCLEQ_LOOP functions first appeared in NetBSD 4.0.