diff options
author | dim <dim@FreeBSD.org> | 2015-09-22 09:50:11 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-09-22 09:50:11 +0000 |
commit | 3715394e84505ef5709d6a973b555868e512038e (patch) | |
tree | 2fe2a49c48673e7324d1d5c28491a1684a358180 | |
parent | fb090a675ae78b4b2524b69e42790a8308637cde (diff) | |
parent | 87b707ed34009ce34c69145b17a47c384047cf46 (diff) | |
download | FreeBSD-src-3715394e84505ef5709d6a973b555868e512038e.zip FreeBSD-src-3715394e84505ef5709d6a973b555868e512038e.tar.gz |
Merge ^/head r288035 through r288099.
146 files changed, 1686 insertions, 1429 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index 26f81cd..e11b54d 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1357,16 +1357,6 @@ ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/c ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport .endif -# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures -# resulting from missing bug fixes or ELF Toolchain updates. -.if ${MK_CDDL} != "no" -_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \ - cddl/usr.bin/ctfmerge - -${_bt}-cddl/usr.bin/ctfconvert: ${_bt}-cddl/lib/libctf -${_bt}-cddl/usr.bin/ctfmerge: ${_bt}-cddl/lib/libctf -.endif - # Default to building the GPL DTC, but build the BSDL one if users explicitly # request it. _dtc= usr.bin/dtc @@ -1406,7 +1396,6 @@ bootstrap-tools: .PHONY .for _tool in \ ${_clang_tblgen} \ ${_kerberos5_bootstrap_tools} \ - ${_dtrace_tools} \ ${_strfile} \ ${_gperf} \ ${_groff} \ @@ -1502,6 +1491,13 @@ _btxld= usr.sbin/btxld .endif .endif +# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures +# resulting from missing bug fixes or ELF Toolchain updates. +.if ${MK_CDDL} != "no" +_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \ + cddl/usr.bin/ctfmerge +.endif + # If we're given an XAS, don't build binutils. .if ${XAS:M/*} == "" .if ${MK_BINUTILS_BOOTSTRAP} != "no" @@ -1545,6 +1541,7 @@ cross-tools: .MAKE ${_clang} \ ${_binutils} \ ${_elftctools} \ + ${_dtrace_tools} \ ${_cc} \ ${_btxld} \ ${_crunchide} \ diff --git a/contrib/binutils/opcodes/arm-dis.c b/contrib/binutils/opcodes/arm-dis.c index 2af8fda..b6ce5c6 100644 --- a/contrib/binutils/opcodes/arm-dis.c +++ b/contrib/binutils/opcodes/arm-dis.c @@ -1767,7 +1767,7 @@ print_insn_coprocessor (bfd_vma pc, struct disassemble_info *info, long given, /* Is ``imm'' a negative number? */ if (imm & 0x40) - imm |= (-1 << 7); + imm |= -(1 << 7); func (stream, "%d", imm); } diff --git a/contrib/jemalloc/ChangeLog b/contrib/jemalloc/ChangeLog index 0cf887c..58e4462 100644 --- a/contrib/jemalloc/ChangeLog +++ b/contrib/jemalloc/ChangeLog @@ -4,6 +4,76 @@ brevity. Much more detail can be found in the git revision history: https://github.com/jemalloc/jemalloc +* 4.0.2 (September 21, 2015) + + This bugfix release addresses a few bugs specific to heap profiling. + + Bug fixes: + - Fix ixallocx_prof_sample() to never modify nor create sampled small + allocations. xallocx() is in general incapable of moving small allocations, + so this fix removes buggy code without loss of generality. + - Fix irallocx_prof_sample() to always allocate large regions, even when + alignment is non-zero. + - Fix prof_alloc_rollback() to read tdata from thread-specific data rather + than dereferencing a potentially invalid tctx. + +* 4.0.1 (September 15, 2015) + + This is a bugfix release that is somewhat high risk due to the amount of + refactoring required to address deep xallocx() problems. As a side effect of + these fixes, xallocx() now tries harder to partially fulfill requests for + optional extra space. Note that a couple of minor heap profiling + optimizations are included, but these are better thought of as performance + fixes that were integral to disovering most of the other bugs. + + Optimizations: + - Avoid a chunk metadata read in arena_prof_tctx_set(), since it is in the + fast path when heap profiling is enabled. Additionally, split a special + case out into arena_prof_tctx_reset(), which also avoids chunk metadata + reads. + - Optimize irallocx_prof() to optimistically update the sampler state. The + prior implementation appears to have been a holdover from when + rallocx()/xallocx() functionality was combined as rallocm(). + + Bug fixes: + - Fix TLS configuration such that it is enabled by default for platforms on + which it works correctly. + - Fix arenas_cache_cleanup() and arena_get_hard() to handle + allocation/deallocation within the application's thread-specific data + cleanup functions even after arenas_cache is torn down. + - Fix xallocx() bugs related to size+extra exceeding HUGE_MAXCLASS. + - Fix chunk purge hook calls for in-place huge shrinking reallocation to + specify the old chunk size rather than the new chunk size. This bug caused + no correctness issues for the default chunk purge function, but was + visible to custom functions set via the "arena.<i>.chunk_hooks" mallctl. + - Fix heap profiling bugs: + + Fix heap profiling to distinguish among otherwise identical sample sites + with interposed resets (triggered via the "prof.reset" mallctl). This bug + could cause data structure corruption that would most likely result in a + segfault. + + Fix irealloc_prof() to prof_alloc_rollback() on OOM. + + Make one call to prof_active_get_unlocked() per allocation event, and use + the result throughout the relevant functions that handle an allocation + event. Also add a missing check in prof_realloc(). These fixes protect + allocation events against concurrent prof_active changes. + + Fix ixallocx_prof() to pass usize_max and zero to ixallocx_prof_sample() + in the correct order. + + Fix prof_realloc() to call prof_free_sampled_object() after calling + prof_malloc_sample_object(). Prior to this fix, if tctx and old_tctx were + the same, the tctx could have been prematurely destroyed. + - Fix portability bugs: + + Don't bitshift by negative amounts when encoding/decoding run sizes in + chunk header maps. This affected systems with page sizes greater than 8 + KiB. + + Rename index_t to szind_t to avoid an existing type on Solaris. + + Add JEMALLOC_CXX_THROW to the memalign() function prototype, in order to + match glibc and avoid compilation errors when including both + jemalloc/jemalloc.h and malloc.h in C++ code. + + Don't assume that /bin/sh is appropriate when running size_classes.sh + during configuration. + + Consider __sparcv9 a synonym for __sparc64__ when defining LG_QUANTUM. + + Link tests to librt if it contains clock_gettime(2). + * 4.0.0 (August 17, 2015) This version contains many speed and space optimizations, both minor and diff --git a/contrib/jemalloc/FREEBSD-diffs b/contrib/jemalloc/FREEBSD-diffs index 7d6955d..25e823c 100644 --- a/contrib/jemalloc/FREEBSD-diffs +++ b/contrib/jemalloc/FREEBSD-diffs @@ -47,7 +47,7 @@ index 8fc774b..fdbef95 100644 + </refsect1> </refentry> diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in -index 7a137b6..b0001e9 100644 +index 8536a3e..0c2a81f 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -8,6 +8,9 @@ @@ -111,10 +111,10 @@ index f051f29..561378f 100644 #endif /* JEMALLOC_H_EXTERNS */ diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt -index dbf6aa7..f87dba8 100644 +index a90021a..34904bf 100644 --- a/include/jemalloc/internal/private_symbols.txt +++ b/include/jemalloc/internal/private_symbols.txt -@@ -277,7 +277,6 @@ iralloct_realign +@@ -280,7 +280,6 @@ iralloct_realign isalloc isdalloct isqalloc @@ -282,7 +282,7 @@ index f943891..47d032c 100755 +#include "jemalloc_FreeBSD.h" EOF diff --git a/src/jemalloc.c b/src/jemalloc.c -index ed7863b..d078a1f 100644 +index 5a2d324..b6cbb79 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -4,6 +4,10 @@ @@ -296,7 +296,7 @@ index ed7863b..d078a1f 100644 /* Runtime configuration options. */ const char *je_malloc_conf JEMALLOC_ATTR(weak); bool opt_abort = -@@ -2475,6 +2479,107 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr) +@@ -2490,6 +2494,107 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr) */ /******************************************************************************/ /* @@ -404,7 +404,7 @@ index ed7863b..d078a1f 100644 * The following functions are used by threading libraries for protection of * malloc during fork(). */ -@@ -2575,4 +2680,11 @@ jemalloc_postfork_child(void) +@@ -2590,4 +2695,11 @@ jemalloc_postfork_child(void) ctl_postfork_child(); } diff --git a/contrib/jemalloc/VERSION b/contrib/jemalloc/VERSION index 6802c56..210a4fe 100644 --- a/contrib/jemalloc/VERSION +++ b/contrib/jemalloc/VERSION @@ -1 +1 @@ -4.0.0-0-g6e98caf8f064482b9ab292ef3638dea67420bbc2 +4.0.2-0-g486d249fb4715fd3de679b6c2a04f7e657883111 diff --git a/contrib/jemalloc/doc/jemalloc.3 b/contrib/jemalloc/doc/jemalloc.3 index 2afb862..2582062 100644 --- a/contrib/jemalloc/doc/jemalloc.3 +++ b/contrib/jemalloc/doc/jemalloc.3 @@ -2,12 +2,12 @@ .\" Title: JEMALLOC .\" Author: Jason Evans .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> -.\" Date: 08/18/2015 +.\" Date: 09/21/2015 .\" Manual: User Manual -.\" Source: jemalloc 4.0.0-0-g6e98caf8f064482b9ab292ef3638dea67420bbc2 +.\" Source: jemalloc 4.0.2-0-g486d249fb4715fd3de679b6c2a04f7e657883111 .\" Language: English .\" -.TH "JEMALLOC" "3" "08/18/2015" "jemalloc 4.0.0-0-g6e98caf8f064" "User Manual" +.TH "JEMALLOC" "3" "09/21/2015" "jemalloc 4.0.2-0-g486d249fb471" "User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,7 +31,7 @@ jemalloc \- general purpose memory allocation functions .SH "LIBRARY" .PP -This manual describes jemalloc 4\&.0\&.0\-0\-g6e98caf8f064482b9ab292ef3638dea67420bbc2\&. More information can be found at the +This manual describes jemalloc 4\&.0\&.2\-0\-g486d249fb4715fd3de679b6c2a04f7e657883111\&. More information can be found at the \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&. .PP The following configuration options are enabled in libc\*(Aqs built\-in jemalloc: diff --git a/contrib/jemalloc/include/jemalloc/internal/arena.h b/contrib/jemalloc/include/jemalloc/internal/arena.h index cb015ee..12c6179 100644 --- a/contrib/jemalloc/include/jemalloc/internal/arena.h +++ b/contrib/jemalloc/include/jemalloc/internal/arena.h @@ -39,7 +39,7 @@ typedef struct arena_s arena_t; #ifdef JEMALLOC_ARENA_STRUCTS_A struct arena_run_s { /* Index of bin this run is associated with. */ - index_t binind; + szind_t binind; /* Number of free regions in run. */ unsigned nfree; @@ -424,7 +424,7 @@ extern arena_bin_info_t arena_bin_info[NBINS]; extern size_t map_bias; /* Number of arena chunk header pages. */ extern size_t map_misc_offset; extern size_t arena_maxrun; /* Max run size for arenas. */ -extern size_t arena_maxclass; /* Max size class for arenas. */ +extern size_t large_maxclass; /* Max large size class. */ extern unsigned nlclasses; /* Number of large size classes. */ extern unsigned nhclasses; /* Number of huge size classes. */ @@ -448,7 +448,7 @@ bool arena_lg_dirty_mult_set(arena_t *arena, ssize_t lg_dirty_mult); void arena_maybe_purge(arena_t *arena); void arena_purge_all(arena_t *arena); void arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, - index_t binind, uint64_t prof_accumbytes); + szind_t binind, uint64_t prof_accumbytes); void arena_alloc_junk_small(void *ptr, arena_bin_info_t *bin_info, bool zero); #ifdef JEMALLOC_JET @@ -488,7 +488,7 @@ extern arena_ralloc_junk_large_t *arena_ralloc_junk_large; bool arena_ralloc_no_move(void *ptr, size_t oldsize, size_t size, size_t extra, bool zero); void *arena_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize, - size_t size, size_t extra, size_t alignment, bool zero, tcache_t *tcache); + size_t size, size_t alignment, bool zero, tcache_t *tcache); dss_prec_t arena_dss_prec_get(arena_t *arena); bool arena_dss_prec_set(arena_t *arena, dss_prec_t dss_prec); ssize_t arena_lg_dirty_mult_default_get(void); @@ -519,17 +519,19 @@ arena_chunk_map_misc_t *arena_run_to_miscelm(arena_run_t *run); size_t *arena_mapbitsp_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbitsp_read(size_t *mapbitsp); size_t arena_mapbits_get(arena_chunk_t *chunk, size_t pageind); +size_t arena_mapbits_size_decode(size_t mapbits); size_t arena_mapbits_unallocated_size_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_large_size_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_small_runind_get(arena_chunk_t *chunk, size_t pageind); -index_t arena_mapbits_binind_get(arena_chunk_t *chunk, size_t pageind); +szind_t arena_mapbits_binind_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_dirty_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_unzeroed_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_decommitted_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_large_get(arena_chunk_t *chunk, size_t pageind); size_t arena_mapbits_allocated_get(arena_chunk_t *chunk, size_t pageind); void arena_mapbitsp_write(size_t *mapbitsp, size_t mapbits); +size_t arena_mapbits_size_encode(size_t size); void arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, size_t size, size_t flags); void arena_mapbits_unallocated_size_set(arena_chunk_t *chunk, size_t pageind, @@ -539,21 +541,23 @@ void arena_mapbits_internal_set(arena_chunk_t *chunk, size_t pageind, void arena_mapbits_large_set(arena_chunk_t *chunk, size_t pageind, size_t size, size_t flags); void arena_mapbits_large_binind_set(arena_chunk_t *chunk, size_t pageind, - index_t binind); + szind_t binind); void arena_mapbits_small_set(arena_chunk_t *chunk, size_t pageind, - size_t runind, index_t binind, size_t flags); + size_t runind, szind_t binind, size_t flags); void arena_metadata_allocated_add(arena_t *arena, size_t size); void arena_metadata_allocated_sub(arena_t *arena, size_t size); size_t arena_metadata_allocated_get(arena_t *arena); bool arena_prof_accum_impl(arena_t *arena, uint64_t accumbytes); bool arena_prof_accum_locked(arena_t *arena, uint64_t accumbytes); bool arena_prof_accum(arena_t *arena, uint64_t accumbytes); -index_t arena_ptr_small_binind_get(const void *ptr, size_t mapbits); -index_t arena_bin_index(arena_t *arena, arena_bin_t *bin); +szind_t arena_ptr_small_binind_get(const void *ptr, size_t mapbits); +szind_t arena_bin_index(arena_t *arena, arena_bin_t *bin); unsigned arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr); prof_tctx_t *arena_prof_tctx_get(const void *ptr); -void arena_prof_tctx_set(const void *ptr, prof_tctx_t *tctx); +void arena_prof_tctx_set(const void *ptr, size_t usize, prof_tctx_t *tctx); +void arena_prof_tctx_reset(const void *ptr, size_t usize, + const void *old_ptr, prof_tctx_t *old_tctx); void *arena_malloc(tsd_t *tsd, arena_t *arena, size_t size, bool zero, tcache_t *tcache); arena_t *arena_aalloc(const void *ptr); @@ -653,13 +657,29 @@ arena_mapbits_get(arena_chunk_t *chunk, size_t pageind) } JEMALLOC_ALWAYS_INLINE size_t +arena_mapbits_size_decode(size_t mapbits) +{ + size_t size; + +#if CHUNK_MAP_SIZE_SHIFT > 0 + size = (mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT; +#elif CHUNK_MAP_SIZE_SHIFT == 0 + size = mapbits & CHUNK_MAP_SIZE_MASK; +#else + size = (mapbits & CHUNK_MAP_SIZE_MASK) << -CHUNK_MAP_SIZE_SHIFT; +#endif + + return (size); +} + +JEMALLOC_ALWAYS_INLINE size_t arena_mapbits_unallocated_size_get(arena_chunk_t *chunk, size_t pageind) { size_t mapbits; mapbits = arena_mapbits_get(chunk, pageind); assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == 0); - return ((mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT); + return (arena_mapbits_size_decode(mapbits)); } JEMALLOC_ALWAYS_INLINE size_t @@ -670,7 +690,7 @@ arena_mapbits_large_size_get(arena_chunk_t *chunk, size_t pageind) mapbits = arena_mapbits_get(chunk, pageind); assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)); - return ((mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT); + return (arena_mapbits_size_decode(mapbits)); } JEMALLOC_ALWAYS_INLINE size_t @@ -684,11 +704,11 @@ arena_mapbits_small_runind_get(arena_chunk_t *chunk, size_t pageind) return (mapbits >> CHUNK_MAP_RUNIND_SHIFT); } -JEMALLOC_ALWAYS_INLINE index_t +JEMALLOC_ALWAYS_INLINE szind_t arena_mapbits_binind_get(arena_chunk_t *chunk, size_t pageind) { size_t mapbits; - index_t binind; + szind_t binind; mapbits = arena_mapbits_get(chunk, pageind); binind = (mapbits & CHUNK_MAP_BININD_MASK) >> CHUNK_MAP_BININD_SHIFT; @@ -754,6 +774,23 @@ arena_mapbitsp_write(size_t *mapbitsp, size_t mapbits) *mapbitsp = mapbits; } +JEMALLOC_ALWAYS_INLINE size_t +arena_mapbits_size_encode(size_t size) +{ + size_t mapbits; + +#if CHUNK_MAP_SIZE_SHIFT > 0 + mapbits = size << CHUNK_MAP_SIZE_SHIFT; +#elif CHUNK_MAP_SIZE_SHIFT == 0 + mapbits = size; +#else + mapbits = size >> -CHUNK_MAP_SIZE_SHIFT; +#endif + + assert((mapbits & ~CHUNK_MAP_SIZE_MASK) == 0); + return (mapbits); +} + JEMALLOC_ALWAYS_INLINE void arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, size_t size, size_t flags) @@ -761,11 +798,10 @@ arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, size_t size, size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); assert((size & PAGE_MASK) == 0); - assert(((size << CHUNK_MAP_SIZE_SHIFT) & ~CHUNK_MAP_SIZE_MASK) == 0); assert((flags & CHUNK_MAP_FLAGS_MASK) == flags); assert((flags & CHUNK_MAP_DECOMMITTED) == 0 || (flags & (CHUNK_MAP_DIRTY|CHUNK_MAP_UNZEROED)) == 0); - arena_mapbitsp_write(mapbitsp, (size << CHUNK_MAP_SIZE_SHIFT) | + arena_mapbitsp_write(mapbitsp, arena_mapbits_size_encode(size) | CHUNK_MAP_BININD_INVALID | flags); } @@ -777,10 +813,9 @@ arena_mapbits_unallocated_size_set(arena_chunk_t *chunk, size_t pageind, size_t mapbits = arena_mapbitsp_read(mapbitsp); assert((size & PAGE_MASK) == 0); - assert(((size << CHUNK_MAP_SIZE_SHIFT) & ~CHUNK_MAP_SIZE_MASK) == 0); assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == 0); - arena_mapbitsp_write(mapbitsp, (size << CHUNK_MAP_SIZE_SHIFT) | (mapbits - & ~CHUNK_MAP_SIZE_MASK)); + arena_mapbitsp_write(mapbitsp, arena_mapbits_size_encode(size) | + (mapbits & ~CHUNK_MAP_SIZE_MASK)); } JEMALLOC_ALWAYS_INLINE void @@ -799,18 +834,17 @@ arena_mapbits_large_set(arena_chunk_t *chunk, size_t pageind, size_t size, size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); assert((size & PAGE_MASK) == 0); - assert(((size << CHUNK_MAP_SIZE_SHIFT) & ~CHUNK_MAP_SIZE_MASK) == 0); assert((flags & CHUNK_MAP_FLAGS_MASK) == flags); assert((flags & CHUNK_MAP_DECOMMITTED) == 0 || (flags & (CHUNK_MAP_DIRTY|CHUNK_MAP_UNZEROED)) == 0); - arena_mapbitsp_write(mapbitsp, (size << CHUNK_MAP_SIZE_SHIFT) | + arena_mapbitsp_write(mapbitsp, arena_mapbits_size_encode(size) | CHUNK_MAP_BININD_INVALID | flags | CHUNK_MAP_LARGE | CHUNK_MAP_ALLOCATED); } JEMALLOC_ALWAYS_INLINE void arena_mapbits_large_binind_set(arena_chunk_t *chunk, size_t pageind, - index_t binind) + szind_t binind) { size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); size_t mapbits = arena_mapbitsp_read(mapbitsp); @@ -824,7 +858,7 @@ arena_mapbits_large_binind_set(arena_chunk_t *chunk, size_t pageind, JEMALLOC_ALWAYS_INLINE void arena_mapbits_small_set(arena_chunk_t *chunk, size_t pageind, size_t runind, - index_t binind, size_t flags) + szind_t binind, size_t flags) { size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); @@ -901,10 +935,10 @@ arena_prof_accum(arena_t *arena, uint64_t accumbytes) } } -JEMALLOC_ALWAYS_INLINE index_t +JEMALLOC_ALWAYS_INLINE szind_t arena_ptr_small_binind_get(const void *ptr, size_t mapbits) { - index_t binind; + szind_t binind; binind = (mapbits & CHUNK_MAP_BININD_MASK) >> CHUNK_MAP_BININD_SHIFT; @@ -916,7 +950,7 @@ arena_ptr_small_binind_get(const void *ptr, size_t mapbits) size_t rpages_ind; arena_run_t *run; arena_bin_t *bin; - index_t run_binind, actual_binind; + szind_t run_binind, actual_binind; arena_bin_info_t *bin_info; arena_chunk_map_misc_t *miscelm; void *rpages; @@ -950,10 +984,10 @@ arena_ptr_small_binind_get(const void *ptr, size_t mapbits) # endif /* JEMALLOC_ARENA_INLINE_A */ # ifdef JEMALLOC_ARENA_INLINE_B -JEMALLOC_INLINE index_t +JEMALLOC_INLINE szind_t arena_bin_index(arena_t *arena, arena_bin_t *bin) { - index_t binind = bin - arena->bins; + szind_t binind = bin - arena->bins; assert(binind < NBINS); return (binind); } @@ -1060,7 +1094,7 @@ arena_prof_tctx_get(const void *ptr) } JEMALLOC_INLINE void -arena_prof_tctx_set(const void *ptr, prof_tctx_t *tctx) +arena_prof_tctx_set(const void *ptr, size_t usize, prof_tctx_t *tctx) { arena_chunk_t *chunk; @@ -1070,17 +1104,59 @@ arena_prof_tctx_set(const void *ptr, prof_tctx_t *tctx) chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); if (likely(chunk != ptr)) { size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; + assert(arena_mapbits_allocated_get(chunk, pageind) != 0); - if (unlikely(arena_mapbits_large_get(chunk, pageind) != 0)) { - arena_chunk_map_misc_t *elm = arena_miscelm_get(chunk, - pageind); + if (unlikely(usize > SMALL_MAXCLASS || (uintptr_t)tctx > + (uintptr_t)1U)) { + arena_chunk_map_misc_t *elm; + + assert(arena_mapbits_large_get(chunk, pageind) != 0); + + elm = arena_miscelm_get(chunk, pageind); atomic_write_p(&elm->prof_tctx_pun, tctx); + } else { + /* + * tctx must always be initialized for large runs. + * Assert that the surrounding conditional logic is + * equivalent to checking whether ptr refers to a large + * run. + */ + assert(arena_mapbits_large_get(chunk, pageind) == 0); } } else huge_prof_tctx_set(ptr, tctx); } +JEMALLOC_INLINE void +arena_prof_tctx_reset(const void *ptr, size_t usize, const void *old_ptr, + prof_tctx_t *old_tctx) +{ + + cassert(config_prof); + assert(ptr != NULL); + + if (unlikely(usize > SMALL_MAXCLASS || (ptr == old_ptr && + (uintptr_t)old_tctx > (uintptr_t)1U))) { + arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); + if (likely(chunk != ptr)) { + size_t pageind; + arena_chunk_map_misc_t *elm; + + pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> + LG_PAGE; + assert(arena_mapbits_allocated_get(chunk, pageind) != + 0); + assert(arena_mapbits_large_get(chunk, pageind) != 0); + + elm = arena_miscelm_get(chunk, pageind); + atomic_write_p(&elm->prof_tctx_pun, + (prof_tctx_t *)(uintptr_t)1U); + } else + huge_prof_tctx_reset(ptr); + } +} + JEMALLOC_ALWAYS_INLINE void * arena_malloc(tsd_t *tsd, arena_t *arena, size_t size, bool zero, tcache_t *tcache) @@ -1098,7 +1174,7 @@ arena_malloc(tsd_t *tsd, arena_t *arena, size_t size, bool zero, zero)); } else return (arena_malloc_small(arena, size, zero)); - } else if (likely(size <= arena_maxclass)) { + } else if (likely(size <= large_maxclass)) { /* * Initialize tcache after checking size in order to avoid * infinite recursion during tcache initialization. @@ -1131,7 +1207,7 @@ arena_salloc(const void *ptr, bool demote) size_t ret; arena_chunk_t *chunk; size_t pageind; - index_t binind; + szind_t binind; assert(ptr != NULL); @@ -1190,7 +1266,7 @@ arena_dalloc(tsd_t *tsd, void *ptr, tcache_t *tcache) if (likely((mapbits & CHUNK_MAP_LARGE) == 0)) { /* Small allocation. */ if (likely(tcache != NULL)) { - index_t binind = arena_ptr_small_binind_get(ptr, + szind_t binind = arena_ptr_small_binind_get(ptr, mapbits); tcache_dalloc_small(tsd, tcache, ptr, binind); } else { @@ -1242,7 +1318,7 @@ arena_sdalloc(tsd_t *tsd, void *ptr, size_t size, tcache_t *tcache) if (likely(size <= SMALL_MAXCLASS)) { /* Small allocation. */ if (likely(tcache != NULL)) { - index_t binind = size2index(size); + szind_t binind = size2index(size); tcache_dalloc_small(tsd, tcache, ptr, binind); } else { size_t pageind = ((uintptr_t)ptr - diff --git a/contrib/jemalloc/include/jemalloc/internal/huge.h b/contrib/jemalloc/include/jemalloc/internal/huge.h index 8b6c6ce..ece7af9 100644 --- a/contrib/jemalloc/include/jemalloc/internal/huge.h +++ b/contrib/jemalloc/include/jemalloc/internal/huge.h @@ -13,11 +13,10 @@ void *huge_malloc(tsd_t *tsd, arena_t *arena, size_t size, bool zero, tcache_t *tcache); void *huge_palloc(tsd_t *tsd, arena_t *arena, size_t size, size_t alignment, bool zero, tcache_t *tcache); -bool huge_ralloc_no_move(void *ptr, size_t oldsize, size_t size, - size_t extra, bool zero); +bool huge_ralloc_no_move(void *ptr, size_t oldsize, size_t usize_min, + size_t usize_max, bool zero); void *huge_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize, - size_t size, size_t extra, size_t alignment, bool zero, - tcache_t *tcache); + size_t usize, size_t alignment, bool zero, tcache_t *tcache); #ifdef JEMALLOC_JET typedef void (huge_dalloc_junk_t)(void *, size_t); extern huge_dalloc_junk_t *huge_dalloc_junk; @@ -27,6 +26,7 @@ arena_t *huge_aalloc(const void *ptr); size_t huge_salloc(const void *ptr); prof_tctx_t *huge_prof_tctx_get(const void *ptr); void huge_prof_tctx_set(const void *ptr, prof_tctx_t *tctx); +void huge_prof_tctx_reset(const void *ptr); #endif /* JEMALLOC_H_EXTERNS */ /******************************************************************************/ diff --git a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h index d9d8b5b..6c3cc18 100644 --- a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h +++ b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h @@ -181,7 +181,7 @@ static const bool config_cache_oblivious = #include "jemalloc/internal/jemalloc_internal_macros.h" /* Size class index type. */ -typedef unsigned index_t; +typedef unsigned szind_t; /* * Flags bits: @@ -229,7 +229,7 @@ typedef unsigned index_t; # ifdef __alpha__ # define LG_QUANTUM 4 # endif -# ifdef __sparc64__ +# if (defined(__sparc64__) || defined(__sparcv9)) # define LG_QUANTUM 4 # endif # if (defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)) @@ -508,12 +508,12 @@ void jemalloc_postfork_child(void); #include "jemalloc/internal/huge.h" #ifndef JEMALLOC_ENABLE_INLINE -index_t size2index_compute(size_t size); -index_t size2index_lookup(size_t size); -index_t size2index(size_t size); -size_t index2size_compute(index_t index); -size_t index2size_lookup(index_t index); -size_t index2size(index_t index); +szind_t size2index_compute(size_t size); +szind_t size2index_lookup(size_t size); +szind_t size2index(size_t size); +size_t index2size_compute(szind_t index); +size_t index2size_lookup(szind_t index); +size_t index2size(szind_t index); size_t s2u_compute(size_t size); size_t s2u_lookup(size_t size); size_t s2u(size_t size); @@ -524,7 +524,7 @@ arena_t *arena_get(tsd_t *tsd, unsigned ind, bool init_if_missing, #endif #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_C_)) -JEMALLOC_INLINE index_t +JEMALLOC_INLINE szind_t size2index_compute(size_t size) { @@ -555,7 +555,7 @@ size2index_compute(size_t size) } } -JEMALLOC_ALWAYS_INLINE index_t +JEMALLOC_ALWAYS_INLINE szind_t size2index_lookup(size_t size) { @@ -568,7 +568,7 @@ size2index_lookup(size_t size) } } -JEMALLOC_ALWAYS_INLINE index_t +JEMALLOC_ALWAYS_INLINE szind_t size2index(size_t size) { @@ -579,7 +579,7 @@ size2index(size_t size) } JEMALLOC_INLINE size_t -index2size_compute(index_t index) +index2size_compute(szind_t index) { #if (NTBINS > 0) @@ -606,7 +606,7 @@ index2size_compute(index_t index) } JEMALLOC_ALWAYS_INLINE size_t -index2size_lookup(index_t index) +index2size_lookup(szind_t index) { size_t ret = (size_t)index2size_tab[index]; assert(ret == index2size_compute(index)); @@ -614,7 +614,7 @@ index2size_lookup(index_t index) } JEMALLOC_ALWAYS_INLINE size_t -index2size(index_t index) +index2size(szind_t index) { assert(index < NSIZES); @@ -702,7 +702,7 @@ sa2u(size_t size, size_t alignment) } /* Try for a large size class. */ - if (likely(size <= arena_maxclass) && likely(alignment < chunksize)) { + if (likely(size <= large_maxclass) && likely(alignment < chunksize)) { /* * We can't achieve subpage alignment, so round up alignment * to the minimum that can actually be supported. @@ -973,7 +973,7 @@ u2rz(size_t usize) size_t ret; if (usize <= SMALL_MAXCLASS) { - index_t binind = size2index(usize); + szind_t binind = size2index(usize); ret = arena_bin_info[binind].redzone_size; } else ret = 0; @@ -1093,7 +1093,7 @@ iralloct(tsd_t *tsd, void *ptr, size_t oldsize, size_t size, size_t alignment, zero, tcache, arena)); } - return (arena_ralloc(tsd, arena, ptr, oldsize, size, 0, alignment, zero, + return (arena_ralloc(tsd, arena, ptr, oldsize, size, alignment, zero, tcache)); } diff --git a/contrib/jemalloc/include/jemalloc/internal/private_namespace.h b/contrib/jemalloc/include/jemalloc/internal/private_namespace.h index 10fab65..ffc4ea2 100644 --- a/contrib/jemalloc/include/jemalloc/internal/private_namespace.h +++ b/contrib/jemalloc/include/jemalloc/internal/private_namespace.h @@ -50,13 +50,14 @@ #define arena_mapbitsp_get JEMALLOC_N(arena_mapbitsp_get) #define arena_mapbitsp_read JEMALLOC_N(arena_mapbitsp_read) #define arena_mapbitsp_write JEMALLOC_N(arena_mapbitsp_write) +#define arena_mapbits_size_decode JEMALLOC_N(arena_mapbits_size_decode) +#define arena_mapbits_size_encode JEMALLOC_N(arena_mapbits_size_encode) #define arena_mapbits_small_runind_get JEMALLOC_N(arena_mapbits_small_runind_get) #define arena_mapbits_small_set JEMALLOC_N(arena_mapbits_small_set) #define arena_mapbits_unallocated_set JEMALLOC_N(arena_mapbits_unallocated_set) #define arena_mapbits_unallocated_size_get JEMALLOC_N(arena_mapbits_unallocated_size_get) #define arena_mapbits_unallocated_size_set JEMALLOC_N(arena_mapbits_unallocated_size_set) #define arena_mapbits_unzeroed_get JEMALLOC_N(arena_mapbits_unzeroed_get) -#define arena_maxclass JEMALLOC_N(arena_maxclass) #define arena_maxrun JEMALLOC_N(arena_maxrun) #define arena_maybe_purge JEMALLOC_N(arena_maybe_purge) #define arena_metadata_allocated_add JEMALLOC_N(arena_metadata_allocated_add) @@ -79,6 +80,7 @@ #define arena_prof_accum_locked JEMALLOC_N(arena_prof_accum_locked) #define arena_prof_promoted JEMALLOC_N(arena_prof_promoted) #define arena_prof_tctx_get JEMALLOC_N(arena_prof_tctx_get) +#define arena_prof_tctx_reset JEMALLOC_N(arena_prof_tctx_reset) #define arena_prof_tctx_set JEMALLOC_N(arena_prof_tctx_set) #define arena_ptr_small_binind_get JEMALLOC_N(arena_ptr_small_binind_get) #define arena_purge_all JEMALLOC_N(arena_purge_all) @@ -249,6 +251,7 @@ #define huge_malloc JEMALLOC_N(huge_malloc) #define huge_palloc JEMALLOC_N(huge_palloc) #define huge_prof_tctx_get JEMALLOC_N(huge_prof_tctx_get) +#define huge_prof_tctx_reset JEMALLOC_N(huge_prof_tctx_reset) #define huge_prof_tctx_set JEMALLOC_N(huge_prof_tctx_set) #define huge_ralloc JEMALLOC_N(huge_ralloc) #define huge_ralloc_no_move JEMALLOC_N(huge_ralloc_no_move) @@ -282,6 +285,7 @@ #define jemalloc_postfork_child JEMALLOC_N(jemalloc_postfork_child) #define jemalloc_postfork_parent JEMALLOC_N(jemalloc_postfork_parent) #define jemalloc_prefork JEMALLOC_N(jemalloc_prefork) +#define large_maxclass JEMALLOC_N(large_maxclass) #define lg_floor JEMALLOC_N(lg_floor) #define malloc_cprintf JEMALLOC_N(malloc_cprintf) #define malloc_mutex_init JEMALLOC_N(malloc_mutex_init) @@ -376,6 +380,7 @@ #define prof_sample_accum_update JEMALLOC_N(prof_sample_accum_update) #define prof_sample_threshold_update JEMALLOC_N(prof_sample_threshold_update) #define prof_tctx_get JEMALLOC_N(prof_tctx_get) +#define prof_tctx_reset JEMALLOC_N(prof_tctx_reset) #define prof_tctx_set JEMALLOC_N(prof_tctx_set) #define prof_tdata_cleanup JEMALLOC_N(prof_tdata_cleanup) #define prof_tdata_get JEMALLOC_N(prof_tdata_get) diff --git a/contrib/jemalloc/include/jemalloc/internal/prof.h b/contrib/jemalloc/include/jemalloc/internal/prof.h index 2e22711..e5198c3 100644 --- a/contrib/jemalloc/include/jemalloc/internal/prof.h +++ b/contrib/jemalloc/include/jemalloc/internal/prof.h @@ -90,10 +90,11 @@ struct prof_tctx_s { prof_tdata_t *tdata; /* - * Copy of tdata->thr_uid, necessary because tdata may be defunct during - * teardown. + * Copy of tdata->thr_{uid,discrim}, necessary because tdata may be + * defunct during teardown. */ uint64_t thr_uid; + uint64_t thr_discrim; /* Profiling counters, protected by tdata->lock. */ prof_cnt_t cnts; @@ -330,14 +331,18 @@ bool prof_gdump_get_unlocked(void); prof_tdata_t *prof_tdata_get(tsd_t *tsd, bool create); bool prof_sample_accum_update(tsd_t *tsd, size_t usize, bool commit, prof_tdata_t **tdata_out); -prof_tctx_t *prof_alloc_prep(tsd_t *tsd, size_t usize, bool update); +prof_tctx_t *prof_alloc_prep(tsd_t *tsd, size_t usize, bool prof_active, + bool update); prof_tctx_t *prof_tctx_get(const void *ptr); -void prof_tctx_set(const void *ptr, prof_tctx_t *tctx); +void prof_tctx_set(const void *ptr, size_t usize, prof_tctx_t *tctx); +void prof_tctx_reset(const void *ptr, size_t usize, const void *old_ptr, + prof_tctx_t *tctx); void prof_malloc_sample_object(const void *ptr, size_t usize, prof_tctx_t *tctx); void prof_malloc(const void *ptr, size_t usize, prof_tctx_t *tctx); void prof_realloc(tsd_t *tsd, const void *ptr, size_t usize, - prof_tctx_t *tctx, bool updated, size_t old_usize, prof_tctx_t *old_tctx); + prof_tctx_t *tctx, bool prof_active, bool updated, const void *old_ptr, + size_t old_usize, prof_tctx_t *old_tctx); void prof_free(tsd_t *tsd, const void *ptr, size_t usize); #endif @@ -402,13 +407,24 @@ prof_tctx_get(const void *ptr) } JEMALLOC_ALWAYS_INLINE void -prof_tctx_set(const void *ptr, prof_tctx_t *tctx) +prof_tctx_set(const void *ptr, size_t usize, prof_tctx_t *tctx) { cassert(config_prof); assert(ptr != NULL); - arena_prof_tctx_set(ptr, tctx); + arena_prof_tctx_set(ptr, usize, tctx); +} + +JEMALLOC_ALWAYS_INLINE void +prof_tctx_reset(const void *ptr, size_t usize, const void *old_ptr, + prof_tctx_t *old_tctx) +{ + + cassert(config_prof); + assert(ptr != NULL); + + arena_prof_tctx_reset(ptr, usize, old_ptr, old_tctx); } JEMALLOC_ALWAYS_INLINE bool @@ -442,7 +458,7 @@ prof_sample_accum_update(tsd_t *tsd, size_t usize, bool update, } JEMALLOC_ALWAYS_INLINE prof_tctx_t * -prof_alloc_prep(tsd_t *tsd, size_t usize, bool update) +prof_alloc_prep(tsd_t *tsd, size_t usize, bool prof_active, bool update) { prof_tctx_t *ret; prof_tdata_t *tdata; @@ -450,8 +466,8 @@ prof_alloc_prep(tsd_t *tsd, size_t usize, bool update) assert(usize == s2u(usize)); - if (!prof_active_get_unlocked() || likely(prof_sample_accum_update(tsd, - usize, update, &tdata))) + if (!prof_active || likely(prof_sample_accum_update(tsd, usize, update, + &tdata))) ret = (prof_tctx_t *)(uintptr_t)1U; else { bt_init(&bt, tdata->vec); @@ -473,22 +489,24 @@ prof_malloc(const void *ptr, size_t usize, prof_tctx_t *tctx) if (unlikely((uintptr_t)tctx > (uintptr_t)1U)) prof_malloc_sample_object(ptr, usize, tctx); else - prof_tctx_set(ptr, (prof_tctx_t *)(uintptr_t)1U); + prof_tctx_set(ptr, usize, (prof_tctx_t *)(uintptr_t)1U); } JEMALLOC_ALWAYS_INLINE void prof_realloc(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx, - bool updated, size_t old_usize, prof_tctx_t *old_tctx) + bool prof_active, bool updated, const void *old_ptr, size_t old_usize, + prof_tctx_t *old_tctx) { + bool sampled, old_sampled; cassert(config_prof); assert(ptr != NULL || (uintptr_t)tctx <= (uintptr_t)1U); - if (!updated && ptr != NULL) { + if (prof_active && !updated && ptr != NULL) { assert(usize == isalloc(ptr, true)); if (prof_sample_accum_update(tsd, usize, true, NULL)) { /* - * Don't sample. The usize passed to PROF_ALLOC_PREP() + * Don't sample. The usize passed to prof_alloc_prep() * was larger than what actually got allocated, so a * backtrace was captured for this allocation, even * though its actual usize was insufficient to cross the @@ -498,12 +516,16 @@ prof_realloc(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx, } } - if (unlikely((uintptr_t)old_tctx > (uintptr_t)1U)) - prof_free_sampled_object(tsd, old_usize, old_tctx); - if (unlikely((uintptr_t)tctx > (uintptr_t)1U)) + sampled = ((uintptr_t)tctx > (uintptr_t)1U); + old_sampled = ((uintptr_t)old_tctx > (uintptr_t)1U); + + if (unlikely(sampled)) prof_malloc_sample_object(ptr, usize, tctx); else - prof_tctx_set(ptr, (prof_tctx_t *)(uintptr_t)1U); + prof_tctx_reset(ptr, usize, old_ptr, old_tctx); + + if (unlikely(old_sampled)) + prof_free_sampled_object(tsd, old_usize, old_tctx); } JEMALLOC_ALWAYS_INLINE void diff --git a/contrib/jemalloc/include/jemalloc/internal/size_classes.h b/contrib/jemalloc/include/jemalloc/internal/size_classes.h index eed6fbd..4ca58a1 100644 --- a/contrib/jemalloc/include/jemalloc/internal/size_classes.h +++ b/contrib/jemalloc/include/jemalloc/internal/size_classes.h @@ -25,6 +25,7 @@ * LOOKUP_MAXCLASS: Maximum size class included in lookup table. * SMALL_MAXCLASS: Maximum small size class. * LG_LARGE_MINCLASS: Lg of minimum large size class. + * HUGE_MAXCLASS: Maximum (huge) size class. */ #define LG_SIZE_CLASS_GROUP 2 @@ -180,6 +181,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11)) #define LG_LARGE_MINCLASS 14 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 13) @@ -333,6 +335,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 14) + (((size_t)3) << 12)) #define LG_LARGE_MINCLASS 15 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 14) @@ -486,6 +489,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 15) + (((size_t)3) << 13)) #define LG_LARGE_MINCLASS 16 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 16) @@ -639,6 +643,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 17) + (((size_t)3) << 15)) #define LG_LARGE_MINCLASS 18 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 12) @@ -789,6 +794,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11)) #define LG_LARGE_MINCLASS 14 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 13) @@ -939,6 +945,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 14) + (((size_t)3) << 12)) #define LG_LARGE_MINCLASS 15 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 14) @@ -1089,6 +1096,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 15) + (((size_t)3) << 13)) #define LG_LARGE_MINCLASS 16 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 16) @@ -1239,6 +1247,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 17) + (((size_t)3) << 15)) #define LG_LARGE_MINCLASS 18 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 12) @@ -1387,6 +1396,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11)) #define LG_LARGE_MINCLASS 14 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 13) @@ -1535,6 +1545,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 14) + (((size_t)3) << 12)) #define LG_LARGE_MINCLASS 15 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 14) @@ -1683,6 +1694,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 15) + (((size_t)3) << 13)) #define LG_LARGE_MINCLASS 16 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 16) @@ -1831,6 +1843,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 17) + (((size_t)3) << 15)) #define LG_LARGE_MINCLASS 18 +#define HUGE_MAXCLASS ((((size_t)1) << 31) + (((size_t)3) << 29)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 12) @@ -2144,6 +2157,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11)) #define LG_LARGE_MINCLASS 14 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 13) @@ -2457,6 +2471,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 14) + (((size_t)3) << 12)) #define LG_LARGE_MINCLASS 15 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 14) @@ -2770,6 +2785,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 15) + (((size_t)3) << 13)) #define LG_LARGE_MINCLASS 16 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 16) @@ -3083,6 +3099,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 17) + (((size_t)3) << 15)) #define LG_LARGE_MINCLASS 18 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 12) @@ -3393,6 +3410,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11)) #define LG_LARGE_MINCLASS 14 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 13) @@ -3703,6 +3721,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 14) + (((size_t)3) << 12)) #define LG_LARGE_MINCLASS 15 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 14) @@ -4013,6 +4032,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 15) + (((size_t)3) << 13)) #define LG_LARGE_MINCLASS 16 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 16) @@ -4323,6 +4343,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 17) + (((size_t)3) << 15)) #define LG_LARGE_MINCLASS 18 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 12) @@ -4631,6 +4652,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11)) #define LG_LARGE_MINCLASS 14 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 13) @@ -4939,6 +4961,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 14) + (((size_t)3) << 12)) #define LG_LARGE_MINCLASS 15 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 14) @@ -5247,6 +5270,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 15) + (((size_t)3) << 13)) #define LG_LARGE_MINCLASS 16 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 16) @@ -5555,6 +5579,7 @@ #define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9)) #define SMALL_MAXCLASS ((((size_t)1) << 17) + (((size_t)3) << 15)) #define LG_LARGE_MINCLASS 18 +#define HUGE_MAXCLASS ((((size_t)1) << 63) + (((size_t)3) << 61)) #endif #ifndef SIZE_CLASSES_DEFINED diff --git a/contrib/jemalloc/include/jemalloc/internal/tcache.h b/contrib/jemalloc/include/jemalloc/internal/tcache.h index 493f457..5079cd2 100644 --- a/contrib/jemalloc/include/jemalloc/internal/tcache.h +++ b/contrib/jemalloc/include/jemalloc/internal/tcache.h @@ -77,7 +77,7 @@ struct tcache_s { ql_elm(tcache_t) link; /* Used for aggregating stats. */ uint64_t prof_accumbytes;/* Cleared after arena_prof_accum(). */ unsigned ev_cnt; /* Event count since incremental GC. */ - index_t next_gc_bin; /* Next bin to GC. */ + szind_t next_gc_bin; /* Next bin to GC. */ tcache_bin_t tbins[1]; /* Dynamically sized. */ /* * The pointer stacks associated with tbins follow as a contiguous @@ -126,10 +126,10 @@ extern tcaches_t *tcaches; size_t tcache_salloc(const void *ptr); void tcache_event_hard(tsd_t *tsd, tcache_t *tcache); void *tcache_alloc_small_hard(tsd_t *tsd, arena_t *arena, tcache_t *tcache, - tcache_bin_t *tbin, index_t binind); + tcache_bin_t *tbin, szind_t binind); void tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin, - index_t binind, unsigned rem); -void tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, index_t binind, + szind_t binind, unsigned rem); +void tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind, unsigned rem, tcache_t *tcache); void tcache_arena_associate(tcache_t *tcache, arena_t *arena); void tcache_arena_reassociate(tcache_t *tcache, arena_t *oldarena, @@ -161,7 +161,7 @@ void *tcache_alloc_small(tsd_t *tsd, arena_t *arena, tcache_t *tcache, void *tcache_alloc_large(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size, bool zero); void tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, - index_t binind); + szind_t binind); void tcache_dalloc_large(tsd_t *tsd, tcache_t *tcache, void *ptr, size_t size); tcache_t *tcaches_get(tsd_t *tsd, unsigned ind); @@ -267,7 +267,7 @@ tcache_alloc_small(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size, bool zero) { void *ret; - index_t binind; + szind_t binind; size_t usize; tcache_bin_t *tbin; @@ -312,7 +312,7 @@ tcache_alloc_large(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size, bool zero) { void *ret; - index_t binind; + szind_t binind; size_t usize; tcache_bin_t *tbin; @@ -360,7 +360,7 @@ tcache_alloc_large(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size, } JEMALLOC_ALWAYS_INLINE void -tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, index_t binind) +tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind) { tcache_bin_t *tbin; tcache_bin_info_t *tbin_info; @@ -386,7 +386,7 @@ tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, index_t binind) JEMALLOC_ALWAYS_INLINE void tcache_dalloc_large(tsd_t *tsd, tcache_t *tcache, void *ptr, size_t size) { - index_t binind; + szind_t binind; tcache_bin_t *tbin; tcache_bin_info_t *tbin_info; diff --git a/contrib/jemalloc/include/jemalloc/internal/tsd.h b/contrib/jemalloc/include/jemalloc/internal/tsd.h index 62a887e..eed7aa0 100644 --- a/contrib/jemalloc/include/jemalloc/internal/tsd.h +++ b/contrib/jemalloc/include/jemalloc/internal/tsd.h @@ -190,7 +190,7 @@ a_name##tsd_boot0(void) \ return (false); \ } \ a_attr void \ -a_name##tsd_boot1() \ +a_name##tsd_boot1(void) \ { \ \ /* Do nothing. */ \ @@ -235,7 +235,7 @@ a_name##tsd_boot0(void) \ return (false); \ } \ a_attr void \ -a_name##tsd_boot1() \ +a_name##tsd_boot1(void) \ { \ \ /* Do nothing. */ \ @@ -345,7 +345,7 @@ a_name##tsd_boot0(void) \ return (false); \ } \ a_attr void \ -a_name##tsd_boot1() \ +a_name##tsd_boot1(void) \ { \ a_name##tsd_wrapper_t *wrapper; \ wrapper = (a_name##tsd_wrapper_t *) \ @@ -467,7 +467,7 @@ a_name##tsd_boot0(void) \ return (false); \ } \ a_attr void \ -a_name##tsd_boot1() \ +a_name##tsd_boot1(void) \ { \ a_name##tsd_wrapper_t *wrapper; \ wrapper = (a_name##tsd_wrapper_t *) \ diff --git a/contrib/jemalloc/include/jemalloc/jemalloc.h b/contrib/jemalloc/include/jemalloc/jemalloc.h index cd8f7da..95a3a51 100644 --- a/contrib/jemalloc/include/jemalloc/jemalloc.h +++ b/contrib/jemalloc/include/jemalloc/jemalloc.h @@ -79,12 +79,12 @@ extern "C" { #include <limits.h> #include <strings.h> -#define JEMALLOC_VERSION "4.0.0-0-g6e98caf8f064482b9ab292ef3638dea67420bbc2" +#define JEMALLOC_VERSION "4.0.2-0-g486d249fb4715fd3de679b6c2a04f7e657883111" #define JEMALLOC_VERSION_MAJOR 4 #define JEMALLOC_VERSION_MINOR 0 -#define JEMALLOC_VERSION_BUGFIX 0 +#define JEMALLOC_VERSION_BUGFIX 2 #define JEMALLOC_VERSION_NREV 0 -#define JEMALLOC_VERSION_GID "6e98caf8f064482b9ab292ef3638dea67420bbc2" +#define JEMALLOC_VERSION_GID "486d249fb4715fd3de679b6c2a04f7e657883111" # define MALLOCX_LG_ALIGN(la) (la) # if LG_SIZEOF_PTR == 2 @@ -234,7 +234,7 @@ JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size( #ifdef JEMALLOC_OVERRIDE_MEMALIGN JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size) - JEMALLOC_ATTR(malloc); + JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc); #endif #ifdef JEMALLOC_OVERRIDE_VALLOC diff --git a/contrib/jemalloc/src/arena.c b/contrib/jemalloc/src/arena.c index af48b39..7f4a6ca 100644 --- a/contrib/jemalloc/src/arena.c +++ b/contrib/jemalloc/src/arena.c @@ -11,7 +11,7 @@ arena_bin_info_t arena_bin_info[NBINS]; size_t map_bias; size_t map_misc_offset; size_t arena_maxrun; /* Max run size for arenas. */ -size_t arena_maxclass; /* Max size class for arenas. */ +size_t large_maxclass; /* Max large size class. */ static size_t small_maxrun; /* Max run size used for small size classes. */ static bool *small_run_tab; /* Valid small run page multiples. */ unsigned nlclasses; /* Number of large size classes. */ @@ -39,7 +39,7 @@ JEMALLOC_INLINE_C arena_chunk_map_misc_t * arena_miscelm_key_create(size_t size) { - return ((arena_chunk_map_misc_t *)((size << CHUNK_MAP_SIZE_SHIFT) | + return ((arena_chunk_map_misc_t *)(arena_mapbits_size_encode(size) | CHUNK_MAP_KEY)); } @@ -58,8 +58,7 @@ arena_miscelm_key_size_get(const arena_chunk_map_misc_t *miscelm) assert(arena_miscelm_is_key(miscelm)); - return (((uintptr_t)miscelm & CHUNK_MAP_SIZE_MASK) >> - CHUNK_MAP_SIZE_SHIFT); + return (arena_mapbits_size_decode((uintptr_t)miscelm)); } JEMALLOC_INLINE_C size_t @@ -73,7 +72,7 @@ arena_miscelm_size_get(arena_chunk_map_misc_t *miscelm) chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(miscelm); pageind = arena_miscelm_to_pageind(miscelm); mapbits = arena_mapbits_get(chunk, pageind); - return ((mapbits & CHUNK_MAP_SIZE_MASK) >> CHUNK_MAP_SIZE_SHIFT); + return (arena_mapbits_size_decode(mapbits)); } JEMALLOC_INLINE_C int @@ -315,7 +314,7 @@ arena_run_reg_dalloc(arena_run_t *run, void *ptr) arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run); size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; size_t mapbits = arena_mapbits_get(chunk, pageind); - index_t binind = arena_ptr_small_binind_get(ptr, mapbits); + szind_t binind = arena_ptr_small_binind_get(ptr, mapbits); arena_bin_info_t *bin_info = &arena_bin_info[binind]; unsigned regind = arena_run_regind(run, bin_info, ptr); @@ -426,7 +425,7 @@ arena_run_split_large_helper(arena_t *arena, arena_run_t *run, size_t size, { arena_chunk_t *chunk; arena_chunk_map_misc_t *miscelm; - size_t flag_dirty, flag_decommitted, run_ind, need_pages, i; + size_t flag_dirty, flag_decommitted, run_ind, need_pages; size_t flag_unzeroed_mask; chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run); @@ -460,6 +459,7 @@ arena_run_split_large_helper(arena_t *arena, arena_run_t *run, size_t size, * The run is clean, so some pages may be zeroed (i.e. * never before touched). */ + size_t i; for (i = 0; i < need_pages; i++) { if (arena_mapbits_unzeroed_get(chunk, run_ind+i) != 0) @@ -508,7 +508,7 @@ arena_run_init_large(arena_t *arena, arena_run_t *run, size_t size, bool zero) static bool arena_run_split_small(arena_t *arena, arena_run_t *run, size_t size, - index_t binind) + szind_t binind) { arena_chunk_t *chunk; arena_chunk_map_misc_t *miscelm; @@ -780,7 +780,7 @@ arena_chunk_dalloc(arena_t *arena, arena_chunk_t *chunk) static void arena_huge_malloc_stats_update(arena_t *arena, size_t usize) { - index_t index = size2index(usize) - nlclasses - NBINS; + szind_t index = size2index(usize) - nlclasses - NBINS; cassert(config_stats); @@ -793,7 +793,7 @@ arena_huge_malloc_stats_update(arena_t *arena, size_t usize) static void arena_huge_malloc_stats_update_undo(arena_t *arena, size_t usize) { - index_t index = size2index(usize) - nlclasses - NBINS; + szind_t index = size2index(usize) - nlclasses - NBINS; cassert(config_stats); @@ -806,7 +806,7 @@ arena_huge_malloc_stats_update_undo(arena_t *arena, size_t usize) static void arena_huge_dalloc_stats_update(arena_t *arena, size_t usize) { - index_t index = size2index(usize) - nlclasses - NBINS; + szind_t index = size2index(usize) - nlclasses - NBINS; cassert(config_stats); @@ -819,7 +819,7 @@ arena_huge_dalloc_stats_update(arena_t *arena, size_t usize) static void arena_huge_dalloc_stats_update_undo(arena_t *arena, size_t usize) { - index_t index = size2index(usize) - nlclasses - NBINS; + szind_t index = size2index(usize) - nlclasses - NBINS; cassert(config_stats); @@ -1125,7 +1125,7 @@ arena_run_alloc_large(arena_t *arena, size_t size, bool zero) } static arena_run_t * -arena_run_alloc_small_helper(arena_t *arena, size_t size, index_t binind) +arena_run_alloc_small_helper(arena_t *arena, size_t size, szind_t binind) { arena_run_t *run = arena_run_first_best_fit(arena, size); if (run != NULL) { @@ -1136,7 +1136,7 @@ arena_run_alloc_small_helper(arena_t *arena, size_t size, index_t binind) } static arena_run_t * -arena_run_alloc_small(arena_t *arena, size_t size, index_t binind) +arena_run_alloc_small(arena_t *arena, size_t size, szind_t binind) { arena_chunk_t *chunk; arena_run_t *run; @@ -1889,7 +1889,7 @@ static arena_run_t * arena_bin_nonfull_run_get(arena_t *arena, arena_bin_t *bin) { arena_run_t *run; - index_t binind; + szind_t binind; arena_bin_info_t *bin_info; /* Look for a usable run. */ @@ -1939,8 +1939,7 @@ arena_bin_nonfull_run_get(arena_t *arena, arena_bin_t *bin) static void * arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin) { - void *ret; - index_t binind; + szind_t binind; arena_bin_info_t *bin_info; arena_run_t *run; @@ -1953,6 +1952,7 @@ arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin) * Another thread updated runcur while this one ran without the * bin lock in arena_bin_nonfull_run_get(). */ + void *ret; assert(bin->runcur->nfree > 0); ret = arena_run_reg_alloc(bin->runcur, bin_info); if (run != NULL) { @@ -1986,13 +1986,11 @@ arena_bin_malloc_hard(arena_t *arena, arena_bin_t *bin) } void -arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, index_t binind, +arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, szind_t binind, uint64_t prof_accumbytes) { unsigned i, nfill; arena_bin_t *bin; - arena_run_t *run; - void *ptr; assert(tbin->ncached == 0); @@ -2002,6 +2000,8 @@ arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, index_t binind, malloc_mutex_lock(&bin->lock); for (i = 0, nfill = (tcache_bin_info[binind].ncached_max >> tbin->lg_fill_div); i < nfill; i++) { + arena_run_t *run; + void *ptr; if ((run = bin->runcur) != NULL && run->nfree > 0) ptr = arena_run_reg_alloc(run, &arena_bin_info[binind]); else @@ -2076,12 +2076,13 @@ arena_redzone_corruption_t *arena_redzone_corruption = static void arena_redzones_validate(void *ptr, arena_bin_info_t *bin_info, bool reset) { - size_t size = bin_info->reg_size; - size_t redzone_size = bin_info->redzone_size; - size_t i; bool error = false; if (opt_junk_alloc) { + size_t size = bin_info->reg_size; + size_t redzone_size = bin_info->redzone_size; + size_t i; + for (i = 1; i <= redzone_size; i++) { uint8_t *byte = (uint8_t *)((uintptr_t)ptr - i); if (*byte != 0xa5) { @@ -2131,7 +2132,7 @@ arena_dalloc_junk_small_t *arena_dalloc_junk_small = void arena_quarantine_junk_small(void *ptr, size_t usize) { - index_t binind; + szind_t binind; arena_bin_info_t *bin_info; cassert(config_fill); assert(opt_junk_free); @@ -2149,7 +2150,7 @@ arena_malloc_small(arena_t *arena, size_t size, bool zero) void *ret; arena_bin_t *bin; arena_run_t *run; - index_t binind; + szind_t binind; binind = size2index(size); assert(binind < NBINS); @@ -2233,7 +2234,7 @@ arena_malloc_large(arena_t *arena, size_t size, bool zero) ret = (void *)((uintptr_t)arena_miscelm_to_rpages(miscelm) + random_offset); if (config_stats) { - index_t index = size2index(usize) - NBINS; + szind_t index = size2index(usize) - NBINS; arena->stats.nmalloc_large++; arena->stats.nrequests_large++; @@ -2326,7 +2327,7 @@ arena_palloc_large(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, ret = arena_miscelm_to_rpages(miscelm); if (config_stats) { - index_t index = size2index(usize) - NBINS; + szind_t index = size2index(usize) - NBINS; arena->stats.nmalloc_large++; arena->stats.nrequests_large++; @@ -2356,7 +2357,7 @@ arena_palloc(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, && (usize & PAGE_MASK) == 0))) { /* Small; alignment doesn't require special run placement. */ ret = arena_malloc(tsd, arena, usize, zero, tcache); - } else if (usize <= arena_maxclass && alignment <= PAGE) { + } else if (usize <= large_maxclass && alignment <= PAGE) { /* * Large; alignment doesn't require special run placement. * However, the cached pointer may be at a random offset from @@ -2367,7 +2368,7 @@ arena_palloc(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, if (config_cache_oblivious) ret = (void *)((uintptr_t)ret & ~PAGE_MASK); } else { - if (likely(usize <= arena_maxclass)) { + if (likely(usize <= large_maxclass)) { ret = arena_palloc_large(tsd, arena, usize, alignment, zero); } else if (likely(alignment <= chunksize)) @@ -2385,7 +2386,7 @@ arena_prof_promoted(const void *ptr, size_t size) { arena_chunk_t *chunk; size_t pageind; - index_t binind; + szind_t binind; cassert(config_prof); assert(ptr != NULL); @@ -2413,7 +2414,7 @@ arena_dissociate_bin_run(arena_chunk_t *chunk, arena_run_t *run, if (run == bin->runcur) bin->runcur = NULL; else { - index_t binind = arena_bin_index(extent_node_arena_get( + szind_t binind = arena_bin_index(extent_node_arena_get( &chunk->node), bin); arena_bin_info_t *bin_info = &arena_bin_info[binind]; @@ -2477,7 +2478,7 @@ arena_dalloc_bin_locked_impl(arena_t *arena, arena_chunk_t *chunk, void *ptr, arena_run_t *run; arena_bin_t *bin; arena_bin_info_t *bin_info; - index_t binind; + szind_t binind; pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; rpages_ind = pageind - arena_mapbits_small_runind_get(chunk, pageind); @@ -2559,7 +2560,7 @@ arena_dalloc_junk_large_t *arena_dalloc_junk_large = JEMALLOC_N(arena_dalloc_junk_large_impl); #endif -void +static void arena_dalloc_large_locked_impl(arena_t *arena, arena_chunk_t *chunk, void *ptr, bool junked) { @@ -2574,7 +2575,7 @@ arena_dalloc_large_locked_impl(arena_t *arena, arena_chunk_t *chunk, if (!junked) arena_dalloc_junk_large(ptr, usize); if (config_stats) { - index_t index = size2index(usize) - NBINS; + szind_t index = size2index(usize) - NBINS; arena->stats.ndalloc_large++; arena->stats.allocated_large -= usize; @@ -2621,8 +2622,8 @@ arena_ralloc_large_shrink(arena_t *arena, arena_chunk_t *chunk, void *ptr, arena_run_trim_tail(arena, chunk, run, oldsize + large_pad, size + large_pad, true); if (config_stats) { - index_t oldindex = size2index(oldsize) - NBINS; - index_t index = size2index(size) - NBINS; + szind_t oldindex = size2index(oldsize) - NBINS; + szind_t index = size2index(size) - NBINS; arena->stats.ndalloc_large++; arena->stats.allocated_large -= oldsize; @@ -2641,42 +2642,42 @@ arena_ralloc_large_shrink(arena_t *arena, arena_chunk_t *chunk, void *ptr, static bool arena_ralloc_large_grow(arena_t *arena, arena_chunk_t *chunk, void *ptr, - size_t oldsize, size_t size, size_t extra, bool zero) + size_t oldsize, size_t usize_min, size_t usize_max, bool zero) { size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; size_t npages = (oldsize + large_pad) >> LG_PAGE; size_t followsize; - size_t usize_min = s2u(size); assert(oldsize == arena_mapbits_large_size_get(chunk, pageind) - large_pad); /* Try to extend the run. */ - assert(usize_min > oldsize); malloc_mutex_lock(&arena->lock); - if (pageind+npages < chunk_npages && - arena_mapbits_allocated_get(chunk, pageind+npages) == 0 && - (followsize = arena_mapbits_unallocated_size_get(chunk, - pageind+npages)) >= usize_min - oldsize) { + if (pageind+npages >= chunk_npages || arena_mapbits_allocated_get(chunk, + pageind+npages) != 0) + goto label_fail; + followsize = arena_mapbits_unallocated_size_get(chunk, pageind+npages); + if (oldsize + followsize >= usize_min) { /* * The next run is available and sufficiently large. Split the * following run, then merge the first part with the existing * allocation. */ arena_run_t *run; - size_t flag_dirty, flag_unzeroed_mask, splitsize, usize; + size_t usize, splitsize, size, flag_dirty, flag_unzeroed_mask; - usize = s2u(size + extra); + usize = usize_max; while (oldsize + followsize < usize) usize = index2size(size2index(usize)-1); assert(usize >= usize_min); + assert(usize >= oldsize); splitsize = usize - oldsize; + if (splitsize == 0) + goto label_fail; run = &arena_miscelm_get(chunk, pageind+npages)->run; - if (arena_run_split_large(arena, run, splitsize, zero)) { - malloc_mutex_unlock(&arena->lock); - return (true); - } + if (arena_run_split_large(arena, run, splitsize, zero)) + goto label_fail; size = oldsize + splitsize; npages = (size + large_pad) >> LG_PAGE; @@ -2700,8 +2701,8 @@ arena_ralloc_large_grow(arena_t *arena, arena_chunk_t *chunk, void *ptr, pageind+npages-1))); if (config_stats) { - index_t oldindex = size2index(oldsize) - NBINS; - index_t index = size2index(size) - NBINS; + szind_t oldindex = size2index(oldsize) - NBINS; + szind_t index = size2index(size) - NBINS; arena->stats.ndalloc_large++; arena->stats.allocated_large -= oldsize; @@ -2718,8 +2719,8 @@ arena_ralloc_large_grow(arena_t *arena, arena_chunk_t *chunk, void *ptr, malloc_mutex_unlock(&arena->lock); return (false); } +label_fail: malloc_mutex_unlock(&arena->lock); - return (true); } @@ -2748,98 +2749,107 @@ arena_ralloc_junk_large_t *arena_ralloc_junk_large = * always fail if growing an object, and the following run is already in use. */ static bool -arena_ralloc_large(void *ptr, size_t oldsize, size_t size, size_t extra, - bool zero) +arena_ralloc_large(void *ptr, size_t oldsize, size_t usize_min, + size_t usize_max, bool zero) { - size_t usize; - - /* Make sure extra can't cause size_t overflow. */ - if (unlikely(extra >= arena_maxclass)) - return (true); + arena_chunk_t *chunk; + arena_t *arena; - usize = s2u(size + extra); - if (usize == oldsize) { - /* Same size class. */ + if (oldsize == usize_max) { + /* Current size class is compatible and maximal. */ return (false); - } else { - arena_chunk_t *chunk; - arena_t *arena; + } - chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); - arena = extent_node_arena_get(&chunk->node); + chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); + arena = extent_node_arena_get(&chunk->node); - if (usize < oldsize) { - /* Fill before shrinking in order avoid a race. */ - arena_ralloc_junk_large(ptr, oldsize, usize); - arena_ralloc_large_shrink(arena, chunk, ptr, oldsize, - usize); - return (false); - } else { - bool ret = arena_ralloc_large_grow(arena, chunk, ptr, - oldsize, size, extra, zero); - if (config_fill && !ret && !zero) { - if (unlikely(opt_junk_alloc)) { - memset((void *)((uintptr_t)ptr + - oldsize), 0xa5, isalloc(ptr, - config_prof) - oldsize); - } else if (unlikely(opt_zero)) { - memset((void *)((uintptr_t)ptr + - oldsize), 0, isalloc(ptr, - config_prof) - oldsize); - } + if (oldsize < usize_max) { + bool ret = arena_ralloc_large_grow(arena, chunk, ptr, oldsize, + usize_min, usize_max, zero); + if (config_fill && !ret && !zero) { + if (unlikely(opt_junk_alloc)) { + memset((void *)((uintptr_t)ptr + oldsize), 0xa5, + isalloc(ptr, config_prof) - oldsize); + } else if (unlikely(opt_zero)) { + memset((void *)((uintptr_t)ptr + oldsize), 0, + isalloc(ptr, config_prof) - oldsize); } - return (ret); } + return (ret); } + + assert(oldsize > usize_max); + /* Fill before shrinking in order avoid a race. */ + arena_ralloc_junk_large(ptr, oldsize, usize_max); + arena_ralloc_large_shrink(arena, chunk, ptr, oldsize, usize_max); + return (false); } bool arena_ralloc_no_move(void *ptr, size_t oldsize, size_t size, size_t extra, bool zero) { + size_t usize_min, usize_max; - if (likely(size <= arena_maxclass)) { + usize_min = s2u(size); + usize_max = s2u(size + extra); + if (likely(oldsize <= large_maxclass && usize_min <= large_maxclass)) { /* * Avoid moving the allocation if the size class can be left the * same. */ - if (likely(oldsize <= arena_maxclass)) { - if (oldsize <= SMALL_MAXCLASS) { - assert( - arena_bin_info[size2index(oldsize)].reg_size - == oldsize); - if ((size + extra <= SMALL_MAXCLASS && - size2index(size + extra) == - size2index(oldsize)) || (size <= oldsize && - size + extra >= oldsize)) + if (oldsize <= SMALL_MAXCLASS) { + assert(arena_bin_info[size2index(oldsize)].reg_size == + oldsize); + if ((usize_max <= SMALL_MAXCLASS && + size2index(usize_max) == size2index(oldsize)) || + (size <= oldsize && usize_max >= oldsize)) + return (false); + } else { + if (usize_max > SMALL_MAXCLASS) { + if (!arena_ralloc_large(ptr, oldsize, usize_min, + usize_max, zero)) return (false); - } else { - assert(size <= arena_maxclass); - if (size + extra > SMALL_MAXCLASS) { - if (!arena_ralloc_large(ptr, oldsize, - size, extra, zero)) - return (false); - } } } /* Reallocation would require a move. */ return (true); - } else - return (huge_ralloc_no_move(ptr, oldsize, size, extra, zero)); + } else { + return (huge_ralloc_no_move(ptr, oldsize, usize_min, usize_max, + zero)); + } +} + +static void * +arena_ralloc_move_helper(tsd_t *tsd, arena_t *arena, size_t usize, + size_t alignment, bool zero, tcache_t *tcache) +{ + + if (alignment == 0) + return (arena_malloc(tsd, arena, usize, zero, tcache)); + usize = sa2u(usize, alignment); + if (usize == 0) + return (NULL); + return (ipalloct(tsd, usize, alignment, zero, tcache, arena)); } void * arena_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize, size_t size, - size_t extra, size_t alignment, bool zero, tcache_t *tcache) + size_t alignment, bool zero, tcache_t *tcache) { void *ret; + size_t usize; - if (likely(size <= arena_maxclass)) { + usize = s2u(size); + if (usize == 0) + return (NULL); + + if (likely(usize <= large_maxclass)) { size_t copysize; /* Try to avoid moving the allocation. */ - if (!arena_ralloc_no_move(ptr, oldsize, size, extra, zero)) + if (!arena_ralloc_no_move(ptr, oldsize, usize, 0, zero)) return (ptr); /* @@ -2847,53 +2857,23 @@ arena_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize, size_t size, * the object. In that case, fall back to allocating new space * and copying. */ - if (alignment != 0) { - size_t usize = sa2u(size + extra, alignment); - if (usize == 0) - return (NULL); - ret = ipalloct(tsd, usize, alignment, zero, tcache, - arena); - } else { - ret = arena_malloc(tsd, arena, size + extra, zero, - tcache); - } - - if (ret == NULL) { - if (extra == 0) - return (NULL); - /* Try again, this time without extra. */ - if (alignment != 0) { - size_t usize = sa2u(size, alignment); - if (usize == 0) - return (NULL); - ret = ipalloct(tsd, usize, alignment, zero, - tcache, arena); - } else { - ret = arena_malloc(tsd, arena, size, zero, - tcache); - } - - if (ret == NULL) - return (NULL); - } + ret = arena_ralloc_move_helper(tsd, arena, usize, alignment, + zero, tcache); + if (ret == NULL) + return (NULL); /* * Junk/zero-filling were already done by * ipalloc()/arena_malloc(). */ - /* - * Copy at most size bytes (not size+extra), since the caller - * has no expectation that the extra bytes will be reliably - * preserved. - */ - copysize = (size < oldsize) ? size : oldsize; + copysize = (usize < oldsize) ? usize : oldsize; JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(ret, copysize); memcpy(ret, ptr, copysize); isqalloc(tsd, ptr, oldsize, tcache); } else { - ret = huge_ralloc(tsd, arena, ptr, oldsize, size, extra, - alignment, zero, tcache); + ret = huge_ralloc(tsd, arena, ptr, oldsize, usize, alignment, + zero, tcache); } return (ret); } @@ -3241,7 +3221,6 @@ small_run_size_init(void) bool arena_boot(void) { - size_t header_size; unsigned i; arena_lg_dirty_mult_default_set(opt_lg_dirty_mult); @@ -3260,7 +3239,7 @@ arena_boot(void) */ map_bias = 0; for (i = 0; i < 3; i++) { - header_size = offsetof(arena_chunk_t, map_bits) + + size_t header_size = offsetof(arena_chunk_t, map_bits) + ((sizeof(arena_chunk_map_bits_t) + sizeof(arena_chunk_map_misc_t)) * (chunk_npages-map_bias)); map_bias = (header_size + PAGE_MASK) >> LG_PAGE; @@ -3272,17 +3251,17 @@ arena_boot(void) arena_maxrun = chunksize - (map_bias << LG_PAGE); assert(arena_maxrun > 0); - arena_maxclass = index2size(size2index(chunksize)-1); - if (arena_maxclass > arena_maxrun) { + large_maxclass = index2size(size2index(chunksize)-1); + if (large_maxclass > arena_maxrun) { /* * For small chunk sizes it's possible for there to be fewer * non-header pages available than are necessary to serve the * size classes just below chunksize. */ - arena_maxclass = arena_maxrun; + large_maxclass = arena_maxrun; } - assert(arena_maxclass > 0); - nlclasses = size2index(arena_maxclass) - size2index(SMALL_MAXCLASS); + assert(large_maxclass > 0); + nlclasses = size2index(large_maxclass) - size2index(SMALL_MAXCLASS); nhclasses = NSIZES - nlclasses - NBINS; bin_info_init(); diff --git a/contrib/jemalloc/src/chunk_dss.c b/contrib/jemalloc/src/chunk_dss.c index de0546d..61fc916 100644 --- a/contrib/jemalloc/src/chunk_dss.c +++ b/contrib/jemalloc/src/chunk_dss.c @@ -69,8 +69,6 @@ void * chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment, bool *zero, bool *commit) { - void *ret; - cassert(have_dss); assert(size > 0 && (size & chunksize_mask) == 0); assert(alignment > 0 && (alignment & chunksize_mask) == 0); @@ -84,9 +82,6 @@ chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment, malloc_mutex_lock(&dss_mtx); if (dss_prev != (void *)-1) { - size_t gap_size, cpad_size; - void *cpad, *dss_next; - intptr_t incr; /* * The loop is necessary to recover from races with other @@ -94,6 +89,9 @@ chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment, * malloc. */ do { + void *ret, *cpad, *dss_next; + size_t gap_size, cpad_size; + intptr_t incr; /* Avoid an unnecessary system call. */ if (new_addr != NULL && dss_max != new_addr) break; diff --git a/contrib/jemalloc/src/chunk_mmap.c b/contrib/jemalloc/src/chunk_mmap.c index 36eb075..b9ba741 100644 --- a/contrib/jemalloc/src/chunk_mmap.c +++ b/contrib/jemalloc/src/chunk_mmap.c @@ -6,14 +6,16 @@ static void * chunk_alloc_mmap_slow(size_t size, size_t alignment, bool *zero, bool *commit) { - void *ret, *pages; - size_t alloc_size, leadsize; + void *ret; + size_t alloc_size; alloc_size = size + alignment - PAGE; /* Beware size_t wrap-around. */ if (alloc_size < size) return (NULL); do { + void *pages; + size_t leadsize; pages = pages_map(NULL, alloc_size); if (pages == NULL) return (NULL); diff --git a/contrib/jemalloc/src/huge.c b/contrib/jemalloc/src/huge.c index 54c2114..f8778db 100644 --- a/contrib/jemalloc/src/huge.c +++ b/contrib/jemalloc/src/huge.c @@ -126,18 +126,19 @@ huge_dalloc_junk_t *huge_dalloc_junk = JEMALLOC_N(huge_dalloc_junk_impl); #endif static void -huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize, - size_t size, size_t extra, bool zero) +huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize_min, + size_t usize_max, bool zero) { - size_t usize_next; + size_t usize, usize_next; extent_node_t *node; arena_t *arena; chunk_hooks_t chunk_hooks = CHUNK_HOOKS_INITIALIZER; bool zeroed; /* Increase usize to incorporate extra. */ - while (usize < s2u(size+extra) && (usize_next = s2u(usize+1)) < oldsize) - usize = usize_next; + for (usize = usize_min; usize < usize_max && (usize_next = s2u(usize+1)) + <= oldsize; usize = usize_next) + ; /* Do nothing. */ if (oldsize == usize) return; @@ -148,11 +149,12 @@ huge_ralloc_no_move_similar(void *ptr, size_t oldsize, size_t usize, /* Fill if necessary (shrinking). */ if (oldsize > usize) { size_t sdiff = oldsize - usize; - zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, ptr, - CHUNK_CEILING(usize), usize, sdiff); if (config_fill && unlikely(opt_junk_free)) { memset((void *)((uintptr_t)ptr + usize), 0x5a, sdiff); zeroed = false; + } else { + zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, ptr, + CHUNK_CEILING(oldsize), usize, sdiff); } } else zeroed = true; @@ -194,6 +196,8 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize) arena = extent_node_arena_get(node); chunk_hooks = chunk_hooks_get(arena); + assert(oldsize > usize); + /* Split excess chunks. */ cdiff = CHUNK_CEILING(oldsize) - CHUNK_CEILING(usize); if (cdiff != 0 && chunk_hooks.split(ptr, CHUNK_CEILING(oldsize), @@ -202,14 +206,15 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize) if (oldsize > usize) { size_t sdiff = oldsize - usize; - zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, - CHUNK_ADDR2BASE((uintptr_t)ptr + usize), - CHUNK_CEILING(usize), CHUNK_ADDR2OFFSET((uintptr_t)ptr + - usize), sdiff); if (config_fill && unlikely(opt_junk_free)) { huge_dalloc_junk((void *)((uintptr_t)ptr + usize), sdiff); zeroed = false; + } else { + zeroed = !chunk_purge_wrapper(arena, &chunk_hooks, + CHUNK_ADDR2BASE((uintptr_t)ptr + usize), + CHUNK_CEILING(oldsize), + CHUNK_ADDR2OFFSET((uintptr_t)ptr + usize), sdiff); } } else zeroed = true; @@ -228,18 +233,11 @@ huge_ralloc_no_move_shrink(void *ptr, size_t oldsize, size_t usize) } static bool -huge_ralloc_no_move_expand(void *ptr, size_t oldsize, size_t size, bool zero) { - size_t usize; +huge_ralloc_no_move_expand(void *ptr, size_t oldsize, size_t usize, bool zero) { extent_node_t *node; arena_t *arena; bool is_zeroed_subchunk, is_zeroed_chunk; - usize = s2u(size); - if (usize == 0) { - /* size_t overflow. */ - return (true); - } - node = huge_node_get(ptr); arena = extent_node_arena_get(node); malloc_mutex_lock(&arena->huge_mtx); @@ -280,89 +278,76 @@ huge_ralloc_no_move_expand(void *ptr, size_t oldsize, size_t size, bool zero) { } bool -huge_ralloc_no_move(void *ptr, size_t oldsize, size_t size, size_t extra, - bool zero) +huge_ralloc_no_move(void *ptr, size_t oldsize, size_t usize_min, + size_t usize_max, bool zero) { - size_t usize; + + assert(s2u(oldsize) == oldsize); /* Both allocations must be huge to avoid a move. */ - if (oldsize < chunksize) + if (oldsize < chunksize || usize_max < chunksize) return (true); - assert(s2u(oldsize) == oldsize); - usize = s2u(size); - if (usize == 0) { - /* size_t overflow. */ - return (true); + if (CHUNK_CEILING(usize_max) > CHUNK_CEILING(oldsize)) { + /* Attempt to expand the allocation in-place. */ + if (!huge_ralloc_no_move_expand(ptr, oldsize, usize_max, zero)) + return (false); + /* Try again, this time with usize_min. */ + if (usize_min < usize_max && CHUNK_CEILING(usize_min) > + CHUNK_CEILING(oldsize) && huge_ralloc_no_move_expand(ptr, + oldsize, usize_min, zero)) + return (false); } /* * Avoid moving the allocation if the existing chunk size accommodates * the new size. */ - if (CHUNK_CEILING(oldsize) >= CHUNK_CEILING(usize) - && CHUNK_CEILING(oldsize) <= CHUNK_CEILING(s2u(size+extra))) { - huge_ralloc_no_move_similar(ptr, oldsize, usize, size, extra, + if (CHUNK_CEILING(oldsize) >= CHUNK_CEILING(usize_min) + && CHUNK_CEILING(oldsize) <= CHUNK_CEILING(usize_max)) { + huge_ralloc_no_move_similar(ptr, oldsize, usize_min, usize_max, zero); return (false); } /* Attempt to shrink the allocation in-place. */ - if (CHUNK_CEILING(oldsize) >= CHUNK_CEILING(usize)) - return (huge_ralloc_no_move_shrink(ptr, oldsize, usize)); + if (CHUNK_CEILING(oldsize) > CHUNK_CEILING(usize_max)) + return (huge_ralloc_no_move_shrink(ptr, oldsize, usize_max)); + return (true); +} - /* Attempt to expand the allocation in-place. */ - if (huge_ralloc_no_move_expand(ptr, oldsize, size + extra, zero)) { - if (extra == 0) - return (true); +static void * +huge_ralloc_move_helper(tsd_t *tsd, arena_t *arena, size_t usize, + size_t alignment, bool zero, tcache_t *tcache) +{ - /* Try again, this time without extra. */ - return (huge_ralloc_no_move_expand(ptr, oldsize, size, zero)); - } - return (false); + if (alignment <= chunksize) + return (huge_malloc(tsd, arena, usize, zero, tcache)); + return (huge_palloc(tsd, arena, usize, alignment, zero, tcache)); } void * -huge_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize, size_t size, - size_t extra, size_t alignment, bool zero, tcache_t *tcache) +huge_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize, size_t usize, + size_t alignment, bool zero, tcache_t *tcache) { void *ret; size_t copysize; /* Try to avoid moving the allocation. */ - if (!huge_ralloc_no_move(ptr, oldsize, size, extra, zero)) + if (!huge_ralloc_no_move(ptr, oldsize, usize, usize, zero)) return (ptr); /* - * size and oldsize are different enough that we need to use a + * usize and oldsize are different enough that we need to use a * different size class. In that case, fall back to allocating new * space and copying. */ - if (alignment > chunksize) { - ret = huge_palloc(tsd, arena, size + extra, alignment, zero, - tcache); - } else - ret = huge_malloc(tsd, arena, size + extra, zero, tcache); - - if (ret == NULL) { - if (extra == 0) - return (NULL); - /* Try again, this time without extra. */ - if (alignment > chunksize) { - ret = huge_palloc(tsd, arena, size, alignment, zero, - tcache); - } else - ret = huge_malloc(tsd, arena, size, zero, tcache); - - if (ret == NULL) - return (NULL); - } + ret = huge_ralloc_move_helper(tsd, arena, usize, alignment, zero, + tcache); + if (ret == NULL) + return (NULL); - /* - * Copy at most size bytes (not size+extra), since the caller has no - * expectation that the extra bytes will be reliably preserved. - */ - copysize = (size < oldsize) ? size : oldsize; + copysize = (usize < oldsize) ? usize : oldsize; memcpy(ret, ptr, copysize); isqalloc(tsd, ptr, oldsize, tcache); return (ret); @@ -439,3 +424,10 @@ huge_prof_tctx_set(const void *ptr, prof_tctx_t *tctx) extent_node_prof_tctx_set(node, tctx); malloc_mutex_unlock(&arena->huge_mtx); } + +void +huge_prof_tctx_reset(const void *ptr) +{ + + huge_prof_tctx_set(ptr, (prof_tctx_t *)(uintptr_t)1U); +} diff --git a/contrib/jemalloc/src/jemalloc.c b/contrib/jemalloc/src/jemalloc.c index d078a1f..b6cbb79 100644 --- a/contrib/jemalloc/src/jemalloc.c +++ b/contrib/jemalloc/src/jemalloc.c @@ -183,13 +183,24 @@ static bool malloc_initializer = NO_INITIALIZER; static malloc_mutex_t init_lock = SRWLOCK_INIT; #else static malloc_mutex_t init_lock; +static bool init_lock_initialized = false; JEMALLOC_ATTR(constructor) static void WINAPI _init_init_lock(void) { - malloc_mutex_init(&init_lock); + /* If another constructor in the same binary is using mallctl to + * e.g. setup chunk hooks, it may end up running before this one, + * and malloc_init_hard will crash trying to lock the uninitialized + * lock. So we force an initialization of the lock in + * malloc_init_hard as well. We don't try to care about atomicity + * of the accessed to the init_lock_initialized boolean, since it + * really only matters early in the process creation, before any + * separate thread normally starts doing anything. */ + if (!init_lock_initialized) + malloc_mutex_init(&init_lock); + init_lock_initialized = true; } #ifdef _MSC_VER @@ -514,17 +525,17 @@ arena_get_hard(tsd_t *tsd, unsigned ind, bool init_if_missing) assert(ind < narenas_actual || !init_if_missing); narenas_cache = (ind < narenas_actual) ? narenas_actual : ind+1; - if (!*arenas_cache_bypassp) { + if (tsd_nominal(tsd) && !*arenas_cache_bypassp) { *arenas_cache_bypassp = true; arenas_cache = (arena_t **)a0malloc(sizeof(arena_t *) * narenas_cache); *arenas_cache_bypassp = false; - } else - arenas_cache = NULL; + } if (arenas_cache == NULL) { /* * This function must always tell the truth, even if - * it's slow, so don't let OOM or recursive allocation + * it's slow, so don't let OOM, thread cleanup (note + * tsd_nominal check), nor recursive allocation * avoidance (note arenas_cache_bypass check) get in the * way. */ @@ -535,6 +546,7 @@ arena_get_hard(tsd_t *tsd, unsigned ind, bool init_if_missing) malloc_mutex_unlock(&arenas_lock); return (arena); } + assert(tsd_nominal(tsd) && !*arenas_cache_bypassp); tsd_arenas_cache_set(tsd, arenas_cache); tsd_narenas_cache_set(tsd, narenas_cache); } @@ -653,8 +665,10 @@ arenas_cache_cleanup(tsd_t *tsd) arena_t **arenas_cache; arenas_cache = tsd_arenas_cache_get(tsd); - if (arenas_cache != NULL) + if (arenas_cache != NULL) { + tsd_arenas_cache_set(tsd, NULL); a0dalloc(arenas_cache); + } } void @@ -1301,6 +1315,9 @@ static bool malloc_init_hard(void) { +#if defined(_WIN32) && _WIN32_WINNT < 0x0600 + _init_init_lock(); +#endif malloc_mutex_lock(&init_lock); if (!malloc_init_hard_needed()) { malloc_mutex_unlock(&init_lock); @@ -1365,7 +1382,7 @@ imalloc_prof(tsd_t *tsd, size_t usize) void *p; prof_tctx_t *tctx; - tctx = prof_alloc_prep(tsd, usize, true); + tctx = prof_alloc_prep(tsd, usize, prof_active_get_unlocked(), true); if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) p = imalloc_prof_sample(tsd, usize, tctx); else @@ -1455,7 +1472,7 @@ imemalign_prof(tsd_t *tsd, size_t alignment, size_t usize) void *p; prof_tctx_t *tctx; - tctx = prof_alloc_prep(tsd, usize, true); + tctx = prof_alloc_prep(tsd, usize, prof_active_get_unlocked(), true); if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) p = imemalign_prof_sample(tsd, alignment, usize, tctx); else @@ -1586,7 +1603,7 @@ icalloc_prof(tsd_t *tsd, size_t usize) void *p; prof_tctx_t *tctx; - tctx = prof_alloc_prep(tsd, usize, true); + tctx = prof_alloc_prep(tsd, usize, prof_active_get_unlocked(), true); if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) p = icalloc_prof_sample(tsd, usize, tctx); else @@ -1669,7 +1686,7 @@ label_return: } static void * -irealloc_prof_sample(tsd_t *tsd, void *oldptr, size_t old_usize, size_t usize, +irealloc_prof_sample(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t usize, prof_tctx_t *tctx) { void *p; @@ -1677,31 +1694,36 @@ irealloc_prof_sample(tsd_t *tsd, void *oldptr, size_t old_usize, size_t usize, if (tctx == NULL) return (NULL); if (usize <= SMALL_MAXCLASS) { - p = iralloc(tsd, oldptr, old_usize, LARGE_MINCLASS, 0, false); + p = iralloc(tsd, old_ptr, old_usize, LARGE_MINCLASS, 0, false); if (p == NULL) return (NULL); arena_prof_promoted(p, usize); } else - p = iralloc(tsd, oldptr, old_usize, usize, 0, false); + p = iralloc(tsd, old_ptr, old_usize, usize, 0, false); return (p); } JEMALLOC_ALWAYS_INLINE_C void * -irealloc_prof(tsd_t *tsd, void *oldptr, size_t old_usize, size_t usize) +irealloc_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t usize) { void *p; + bool prof_active; prof_tctx_t *old_tctx, *tctx; - old_tctx = prof_tctx_get(oldptr); - tctx = prof_alloc_prep(tsd, usize, true); + prof_active = prof_active_get_unlocked(); + old_tctx = prof_tctx_get(old_ptr); + tctx = prof_alloc_prep(tsd, usize, prof_active, true); if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) - p = irealloc_prof_sample(tsd, oldptr, old_usize, usize, tctx); + p = irealloc_prof_sample(tsd, old_ptr, old_usize, usize, tctx); else - p = iralloc(tsd, oldptr, old_usize, usize, 0, false); - if (p == NULL) + p = iralloc(tsd, old_ptr, old_usize, usize, 0, false); + if (unlikely(p == NULL)) { + prof_alloc_rollback(tsd, tctx, true); return (NULL); - prof_realloc(tsd, p, usize, tctx, true, old_usize, old_tctx); + } + prof_realloc(tsd, p, usize, tctx, prof_active, true, old_ptr, old_usize, + old_tctx); return (p); } @@ -1905,6 +1927,7 @@ imallocx_flags_decode_hard(tsd_t *tsd, size_t size, int flags, size_t *usize, *alignment = MALLOCX_ALIGN_GET_SPECIFIED(flags); *usize = sa2u(size, *alignment); } + assert(*usize != 0); *zero = MALLOCX_ZERO_GET(flags); if ((flags & MALLOCX_TCACHE_MASK) != 0) { if ((flags & MALLOCX_TCACHE_MASK) == MALLOCX_TCACHE_NONE) @@ -1947,41 +1970,29 @@ imallocx_flags(tsd_t *tsd, size_t usize, size_t alignment, bool zero, tcache_t *tcache, arena_t *arena) { - if (alignment != 0) + if (unlikely(alignment != 0)) return (ipalloct(tsd, usize, alignment, zero, tcache, arena)); - if (zero) + if (unlikely(zero)) return (icalloct(tsd, usize, tcache, arena)); return (imalloct(tsd, usize, tcache, arena)); } -JEMALLOC_ALWAYS_INLINE_C void * -imallocx_maybe_flags(tsd_t *tsd, size_t size, int flags, size_t usize, - size_t alignment, bool zero, tcache_t *tcache, arena_t *arena) -{ - - if (likely(flags == 0)) - return (imalloc(tsd, size)); - return (imallocx_flags(tsd, usize, alignment, zero, tcache, arena)); -} - static void * -imallocx_prof_sample(tsd_t *tsd, size_t size, int flags, size_t usize, - size_t alignment, bool zero, tcache_t *tcache, arena_t *arena) +imallocx_prof_sample(tsd_t *tsd, size_t usize, size_t alignment, bool zero, + tcache_t *tcache, arena_t *arena) { void *p; if (usize <= SMALL_MAXCLASS) { assert(((alignment == 0) ? s2u(LARGE_MINCLASS) : sa2u(LARGE_MINCLASS, alignment)) == LARGE_MINCLASS); - p = imallocx_maybe_flags(tsd, LARGE_MINCLASS, flags, - LARGE_MINCLASS, alignment, zero, tcache, arena); + p = imallocx_flags(tsd, LARGE_MINCLASS, alignment, zero, tcache, + arena); if (p == NULL) return (NULL); arena_prof_promoted(p, usize); - } else { - p = imallocx_maybe_flags(tsd, size, flags, usize, alignment, - zero, tcache, arena); - } + } else + p = imallocx_flags(tsd, usize, alignment, zero, tcache, arena); return (p); } @@ -1999,13 +2010,12 @@ imallocx_prof(tsd_t *tsd, size_t size, int flags, size_t *usize) if (unlikely(imallocx_flags_decode(tsd, size, flags, usize, &alignment, &zero, &tcache, &arena))) return (NULL); - tctx = prof_alloc_prep(tsd, *usize, true); - if (likely((uintptr_t)tctx == (uintptr_t)1U)) { - p = imallocx_maybe_flags(tsd, size, flags, *usize, alignment, - zero, tcache, arena); - } else if ((uintptr_t)tctx > (uintptr_t)1U) { - p = imallocx_prof_sample(tsd, size, flags, *usize, alignment, - zero, tcache, arena); + tctx = prof_alloc_prep(tsd, *usize, prof_active_get_unlocked(), true); + if (likely((uintptr_t)tctx == (uintptr_t)1U)) + p = imallocx_flags(tsd, *usize, alignment, zero, tcache, arena); + else if ((uintptr_t)tctx > (uintptr_t)1U) { + p = imallocx_prof_sample(tsd, *usize, alignment, zero, tcache, + arena); } else p = NULL; if (unlikely(p == NULL)) { @@ -2080,8 +2090,8 @@ label_oom: } static void * -irallocx_prof_sample(tsd_t *tsd, void *oldptr, size_t old_usize, size_t size, - size_t alignment, size_t usize, bool zero, tcache_t *tcache, arena_t *arena, +irallocx_prof_sample(tsd_t *tsd, void *old_ptr, size_t old_usize, + size_t usize, size_t alignment, bool zero, tcache_t *tcache, arena_t *arena, prof_tctx_t *tctx) { void *p; @@ -2089,13 +2099,13 @@ irallocx_prof_sample(tsd_t *tsd, void *oldptr, size_t old_usize, size_t size, if (tctx == NULL) return (NULL); if (usize <= SMALL_MAXCLASS) { - p = iralloct(tsd, oldptr, old_usize, LARGE_MINCLASS, alignment, + p = iralloct(tsd, old_ptr, old_usize, LARGE_MINCLASS, alignment, zero, tcache, arena); if (p == NULL) return (NULL); arena_prof_promoted(p, usize); } else { - p = iralloct(tsd, oldptr, old_usize, size, alignment, zero, + p = iralloct(tsd, old_ptr, old_usize, usize, alignment, zero, tcache, arena); } @@ -2103,28 +2113,30 @@ irallocx_prof_sample(tsd_t *tsd, void *oldptr, size_t old_usize, size_t size, } JEMALLOC_ALWAYS_INLINE_C void * -irallocx_prof(tsd_t *tsd, void *oldptr, size_t old_usize, size_t size, +irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size, size_t alignment, size_t *usize, bool zero, tcache_t *tcache, arena_t *arena) { void *p; + bool prof_active; prof_tctx_t *old_tctx, *tctx; - old_tctx = prof_tctx_get(oldptr); - tctx = prof_alloc_prep(tsd, *usize, false); + prof_active = prof_active_get_unlocked(); + old_tctx = prof_tctx_get(old_ptr); + tctx = prof_alloc_prep(tsd, *usize, prof_active, true); if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { - p = irallocx_prof_sample(tsd, oldptr, old_usize, size, - alignment, *usize, zero, tcache, arena, tctx); + p = irallocx_prof_sample(tsd, old_ptr, old_usize, *usize, + alignment, zero, tcache, arena, tctx); } else { - p = iralloct(tsd, oldptr, old_usize, size, alignment, zero, + p = iralloct(tsd, old_ptr, old_usize, size, alignment, zero, tcache, arena); } if (unlikely(p == NULL)) { - prof_alloc_rollback(tsd, tctx, false); + prof_alloc_rollback(tsd, tctx, true); return (NULL); } - if (p == oldptr && alignment != 0) { + if (p == old_ptr && alignment != 0) { /* * The allocation did not move, so it is possible that the size * class is smaller than would guarantee the requested @@ -2135,7 +2147,8 @@ irallocx_prof(tsd_t *tsd, void *oldptr, size_t old_usize, size_t size, */ *usize = isalloc(p, config_prof); } - prof_realloc(tsd, p, *usize, tctx, false, old_usize, old_tctx); + prof_realloc(tsd, p, *usize, tctx, prof_active, true, old_ptr, + old_usize, old_tctx); return (p); } @@ -2230,26 +2243,13 @@ ixallocx_helper(void *ptr, size_t old_usize, size_t size, size_t extra, static size_t ixallocx_prof_sample(void *ptr, size_t old_usize, size_t size, size_t extra, - size_t alignment, size_t max_usize, bool zero, prof_tctx_t *tctx) + size_t alignment, bool zero, prof_tctx_t *tctx) { size_t usize; if (tctx == NULL) return (old_usize); - /* Use minimum usize to determine whether promotion may happen. */ - if (((alignment == 0) ? s2u(size) : sa2u(size, alignment)) <= - SMALL_MAXCLASS) { - if (ixalloc(ptr, old_usize, SMALL_MAXCLASS+1, - (SMALL_MAXCLASS+1 >= size+extra) ? 0 : size+extra - - (SMALL_MAXCLASS+1), alignment, zero)) - return (old_usize); - usize = isalloc(ptr, config_prof); - if (max_usize < LARGE_MINCLASS) - arena_prof_promoted(ptr, usize); - } else { - usize = ixallocx_helper(ptr, old_usize, size, extra, alignment, - zero); - } + usize = ixallocx_helper(ptr, old_usize, size, extra, alignment, zero); return (usize); } @@ -2258,9 +2258,11 @@ JEMALLOC_ALWAYS_INLINE_C size_t ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size, size_t extra, size_t alignment, bool zero) { - size_t max_usize, usize; + size_t usize_max, usize; + bool prof_active; prof_tctx_t *old_tctx, *tctx; + prof_active = prof_active_get_unlocked(); old_tctx = prof_tctx_get(ptr); /* * usize isn't knowable before ixalloc() returns when extra is non-zero. @@ -2268,21 +2270,23 @@ ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size, * prof_alloc_prep() to decide whether to capture a backtrace. * prof_realloc() will use the actual usize to decide whether to sample. */ - max_usize = (alignment == 0) ? s2u(size+extra) : sa2u(size+extra, + usize_max = (alignment == 0) ? s2u(size+extra) : sa2u(size+extra, alignment); - tctx = prof_alloc_prep(tsd, max_usize, false); + assert(usize_max != 0); + tctx = prof_alloc_prep(tsd, usize_max, prof_active, false); if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { usize = ixallocx_prof_sample(ptr, old_usize, size, extra, - alignment, zero, max_usize, tctx); + alignment, zero, tctx); } else { usize = ixallocx_helper(ptr, old_usize, size, extra, alignment, zero); } - if (unlikely(usize == old_usize)) { + if (usize == old_usize) { prof_alloc_rollback(tsd, tctx, false); return (usize); } - prof_realloc(tsd, ptr, usize, tctx, false, old_usize, old_tctx); + prof_realloc(tsd, ptr, usize, tctx, prof_active, false, ptr, old_usize, + old_tctx); return (usize); } @@ -2304,6 +2308,17 @@ je_xallocx(void *ptr, size_t size, size_t extra, int flags) tsd = tsd_fetch(); old_usize = isalloc(ptr, config_prof); + + /* Clamp extra if necessary to avoid (size + extra) overflow. */ + if (unlikely(size + extra > HUGE_MAXCLASS)) { + /* Check for size overflow. */ + if (unlikely(size > HUGE_MAXCLASS)) { + usize = old_usize; + goto label_not_resized; + } + extra = HUGE_MAXCLASS - size; + } + if (config_valgrind && unlikely(in_valgrind)) old_rzsize = u2rz(old_usize); diff --git a/contrib/jemalloc/src/prof.c b/contrib/jemalloc/src/prof.c index a05792f..0a08062 100644 --- a/contrib/jemalloc/src/prof.c +++ b/contrib/jemalloc/src/prof.c @@ -139,9 +139,16 @@ prof_tctx_comp(const prof_tctx_t *a, const prof_tctx_t *b) uint64_t b_thr_uid = b->thr_uid; int ret = (a_thr_uid > b_thr_uid) - (a_thr_uid < b_thr_uid); if (ret == 0) { - uint64_t a_tctx_uid = a->tctx_uid; - uint64_t b_tctx_uid = b->tctx_uid; - ret = (a_tctx_uid > b_tctx_uid) - (a_tctx_uid < b_tctx_uid); + uint64_t a_thr_discrim = a->thr_discrim; + uint64_t b_thr_discrim = b->thr_discrim; + ret = (a_thr_discrim > b_thr_discrim) - (a_thr_discrim < + b_thr_discrim); + if (ret == 0) { + uint64_t a_tctx_uid = a->tctx_uid; + uint64_t b_tctx_uid = b->tctx_uid; + ret = (a_tctx_uid > b_tctx_uid) - (a_tctx_uid < + b_tctx_uid); + } } return (ret); } @@ -202,7 +209,7 @@ prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated) */ tdata = prof_tdata_get(tsd, true); if (tdata != NULL) - prof_sample_threshold_update(tctx->tdata); + prof_sample_threshold_update(tdata); } if ((uintptr_t)tctx > (uintptr_t)1U) { @@ -219,7 +226,7 @@ void prof_malloc_sample_object(const void *ptr, size_t usize, prof_tctx_t *tctx) { - prof_tctx_set(ptr, tctx); + prof_tctx_set(ptr, usize, tctx); malloc_mutex_lock(tctx->tdata->lock); tctx->cnts.curobjs++; @@ -791,6 +798,7 @@ prof_lookup(tsd_t *tsd, prof_bt_t *bt) } ret.p->tdata = tdata; ret.p->thr_uid = tdata->thr_uid; + ret.p->thr_discrim = tdata->thr_discrim; memset(&ret.p->cnts, 0, sizeof(prof_cnt_t)); ret.p->gctx = gctx; ret.p->tctx_uid = tdata->tctx_uid_next++; @@ -1569,7 +1577,6 @@ prof_idump(void) { tsd_t *tsd; prof_tdata_t *tdata; - char filename[PATH_MAX + 1]; cassert(config_prof); @@ -1585,6 +1592,7 @@ prof_idump(void) } if (opt_prof_prefix[0] != '\0') { + char filename[PATH_MAX + 1]; malloc_mutex_lock(&prof_dump_seq_mtx); prof_dump_filename(filename, 'i', prof_dump_iseq); prof_dump_iseq++; @@ -1623,7 +1631,6 @@ prof_gdump(void) { tsd_t *tsd; prof_tdata_t *tdata; - char filename[DUMP_FILENAME_BUFSIZE]; cassert(config_prof); @@ -1639,6 +1646,7 @@ prof_gdump(void) } if (opt_prof_prefix[0] != '\0') { + char filename[DUMP_FILENAME_BUFSIZE]; malloc_mutex_lock(&prof_dump_seq_mtx); prof_dump_filename(filename, 'u', prof_dump_useq); prof_dump_useq++; diff --git a/contrib/jemalloc/src/tcache.c b/contrib/jemalloc/src/tcache.c index 3814365..fdafd0c 100644 --- a/contrib/jemalloc/src/tcache.c +++ b/contrib/jemalloc/src/tcache.c @@ -32,7 +32,7 @@ size_t tcache_salloc(const void *ptr) void tcache_event_hard(tsd_t *tsd, tcache_t *tcache) { - index_t binind = tcache->next_gc_bin; + szind_t binind = tcache->next_gc_bin; tcache_bin_t *tbin = &tcache->tbins[binind]; tcache_bin_info_t *tbin_info = &tcache_bin_info[binind]; @@ -72,7 +72,7 @@ tcache_event_hard(tsd_t *tsd, tcache_t *tcache) void * tcache_alloc_small_hard(tsd_t *tsd, arena_t *arena, tcache_t *tcache, - tcache_bin_t *tbin, index_t binind) + tcache_bin_t *tbin, szind_t binind) { void *ret; @@ -87,7 +87,7 @@ tcache_alloc_small_hard(tsd_t *tsd, arena_t *arena, tcache_t *tcache, void tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin, - index_t binind, unsigned rem) + szind_t binind, unsigned rem) { arena_t *arena; void *ptr; @@ -166,7 +166,7 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin, } void -tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, index_t binind, +tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind, unsigned rem, tcache_t *tcache) { arena_t *arena; @@ -496,13 +496,13 @@ tcache_boot(void) unsigned i; /* - * If necessary, clamp opt_lg_tcache_max, now that arena_maxclass is + * If necessary, clamp opt_lg_tcache_max, now that large_maxclass is * known. */ if (opt_lg_tcache_max < 0 || (1U << opt_lg_tcache_max) < SMALL_MAXCLASS) tcache_maxclass = SMALL_MAXCLASS; - else if ((1U << opt_lg_tcache_max) > arena_maxclass) - tcache_maxclass = arena_maxclass; + else if ((1U << opt_lg_tcache_max) > large_maxclass) + tcache_maxclass = large_maxclass; else tcache_maxclass = (1U << opt_lg_tcache_max); diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp index 9839617..fc4b66b 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp @@ -699,7 +699,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { switch (E->getOp()) { case AtomicExpr::AO__c11_atomic_init: - llvm_unreachable("Already handled!"); + llvm_unreachable("Already handled above with EmitAtomicInit!"); case AtomicExpr::AO__c11_atomic_load: case AtomicExpr::AO__atomic_load_n: @@ -785,20 +785,43 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { if (UseLibcall) { bool UseOptimizedLibcall = false; switch (E->getOp()) { + case AtomicExpr::AO__c11_atomic_init: + llvm_unreachable("Already handled above with EmitAtomicInit!"); + case AtomicExpr::AO__c11_atomic_fetch_add: case AtomicExpr::AO__atomic_fetch_add: case AtomicExpr::AO__c11_atomic_fetch_and: case AtomicExpr::AO__atomic_fetch_and: case AtomicExpr::AO__c11_atomic_fetch_or: case AtomicExpr::AO__atomic_fetch_or: + case AtomicExpr::AO__atomic_fetch_nand: case AtomicExpr::AO__c11_atomic_fetch_sub: case AtomicExpr::AO__atomic_fetch_sub: case AtomicExpr::AO__c11_atomic_fetch_xor: case AtomicExpr::AO__atomic_fetch_xor: + case AtomicExpr::AO__atomic_add_fetch: + case AtomicExpr::AO__atomic_and_fetch: + case AtomicExpr::AO__atomic_nand_fetch: + case AtomicExpr::AO__atomic_or_fetch: + case AtomicExpr::AO__atomic_sub_fetch: + case AtomicExpr::AO__atomic_xor_fetch: // For these, only library calls for certain sizes exist. UseOptimizedLibcall = true; break; - default: + + case AtomicExpr::AO__c11_atomic_load: + case AtomicExpr::AO__c11_atomic_store: + case AtomicExpr::AO__c11_atomic_exchange: + case AtomicExpr::AO__c11_atomic_compare_exchange_weak: + case AtomicExpr::AO__c11_atomic_compare_exchange_strong: + case AtomicExpr::AO__atomic_load_n: + case AtomicExpr::AO__atomic_load: + case AtomicExpr::AO__atomic_store_n: + case AtomicExpr::AO__atomic_store: + case AtomicExpr::AO__atomic_exchange_n: + case AtomicExpr::AO__atomic_exchange: + case AtomicExpr::AO__atomic_compare_exchange_n: + case AtomicExpr::AO__atomic_compare_exchange: // Only use optimized library calls for sizes for which they exist. if (Size == 1 || Size == 2 || Size == 4 || Size == 8) UseOptimizedLibcall = true; @@ -820,6 +843,9 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { QualType RetTy; bool HaveRetTy = false; switch (E->getOp()) { + case AtomicExpr::AO__c11_atomic_init: + llvm_unreachable("Already handled!"); + // There is only one libcall for compare an exchange, because there is no // optimisation benefit possible from a libcall version of a weak compare // and exchange. @@ -903,7 +929,49 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, E->getExprLoc(), sizeChars); break; - default: return EmitUnsupportedRValue(E, "atomic library call"); + // T __atomic_fetch_nand_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_fetch_nand: + LibCallName = "__atomic_fetch_nand"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + + // T __atomic_add_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_add_fetch: + LibCallName = "__atomic_add_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, LoweredMemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_and_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_and_fetch: + LibCallName = "__atomic_and_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_or_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_or_fetch: + LibCallName = "__atomic_or_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_sub_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_sub_fetch: + LibCallName = "__atomic_sub_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, LoweredMemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_xor_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_xor_fetch: + LibCallName = "__atomic_xor_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_nand_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_nand_fetch: + LibCallName = "__atomic_nand_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; } // Optimized functions have the size in their name. diff --git a/contrib/openpam/lib/libpam/openpam_constants.c b/contrib/openpam/lib/libpam/openpam_constants.c index 1cdd810..b718af9 100644 --- a/contrib/openpam/lib/libpam/openpam_constants.c +++ b/contrib/openpam/lib/libpam/openpam_constants.c @@ -137,6 +137,9 @@ const char *openpam_policy_path[] = { const char *openpam_module_path[] = { #ifdef OPENPAM_MODULES_DIRECTORY OPENPAM_MODULES_DIRECTORY, +#elif COMPAT_32BIT + "/usr/lib32", + "/usr/local/lib32", #else "/usr/lib", "/usr/local/lib", diff --git a/gnu/lib/csu/Makefile b/gnu/lib/csu/Makefile index 1231443..de78c7e 100644 --- a/gnu/lib/csu/Makefile +++ b/gnu/lib/csu/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -.MAIN: all - .include <src.opts.mk> MK_SSP= no @@ -41,7 +39,14 @@ SRCS+= crtfastmath.c BEGINSRC?= crtstuff.c ENDSRC?= crtstuff.c -all: ${OBJS} ${SOBJS} ${TGTOBJS} +FILES= ${OBJS} ${SOBJS} ${TGTOBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY + ${OBJS} ${SOBJS}: ${SRCS:M*.h} CLEANFILES= ${OBJS} ${SOBJS} ${TGTOBJS} @@ -70,17 +75,6 @@ CLEANFILES+= tm.h tconfig.h options.h optionlist cs-tconfig.h cs-tm.h tm.h tconfig.h options.h: ${CCDIR}/cc_tools/Makefile (cd ${.CURDIR}; ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}) -realinstall: -.for file in ${OBJS} ${SOBJS} ${TGTOBJS} - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${file} ${DESTDIR}${LIBDIR}/${file} -.endfor - -.if ${MK_STAGING} == "yes" -STAGE_DIR= ${STAGE_LIBDIR} -STAGE_FILES= ${OBJS} ${SOBJS} ${TGTOBJS} -staging: stage_files -.endif .NOPATH: ${CLEANFILES} .include <bsd.lib.mk> diff --git a/gnu/usr.bin/binutils/ld/Makefile b/gnu/usr.bin/binutils/ld/Makefile index f6379e2..77d89a2 100644 --- a/gnu/usr.bin/binutils/ld/Makefile +++ b/gnu/usr.bin/binutils/ld/Makefile @@ -46,9 +46,6 @@ CLEANDIRS+= ldscripts CLEANFILES+= ldemul-list.h stringify.sed FILES= ${LDSCRIPTS:S|^|ldscripts/|} -FILESOWN= ${LIBOWN} -FILESGRP= ${LIBGRP} -FILESMODE= ${LIBMODE} FILESDIR= ${SCRIPTDIR} HOST= ${TARGET_TUPLE} diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc index ff77f66..95d5c5e 100644 --- a/lib/csu/Makefile.inc +++ b/lib/csu/Makefile.inc @@ -7,8 +7,3 @@ SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/' NO_WMISSING_VARIABLE_DECLARATIONS= .include "../Makefile.inc" - -.if ${MK_STAGING} == "yes" && ${.TARGETS:Nall} == "" -FILES?= ${OBJS} -FILESDIR?= ${LIBDIR} -.endif diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile index bf4c7b1..9747619 100644 --- a/lib/csu/aarch64/Makefile +++ b/lib/csu/aarch64/Makefile @@ -8,7 +8,13 @@ OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s @@ -37,8 +43,4 @@ Scrt1.s: crt1.c Scrt1.o: Scrt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile index 80d14a7..e9ca6b9 100644 --- a/lib/csu/amd64/Makefile +++ b/lib/csu/amd64/Makefile @@ -9,7 +9,13 @@ CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include CFLAGS+= -fno-omit-frame-pointer -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s @@ -38,8 +44,4 @@ Scrt1.s: crt1.c Scrt1.o: Scrt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile index bf4c7b1..9747619 100644 --- a/lib/csu/arm/Makefile +++ b/lib/csu/arm/Makefile @@ -8,7 +8,13 @@ OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s @@ -37,8 +43,4 @@ Scrt1.s: crt1.c Scrt1.o: Scrt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile index d5ca479..d64f803 100644 --- a/lib/csu/i386/Makefile +++ b/lib/csu/i386/Makefile @@ -8,7 +8,13 @@ OBJS+= gcrt1.o crt1.o Scrt1.o CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s @@ -48,8 +54,4 @@ Scrt1.o: Scrt1_c.o crt1_s.o ${LD} ${_LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o ${OBJCOPY} --localize-symbol _start1 Scrt1.o -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/mips/Makefile b/lib/csu/mips/Makefile index bf4c7b1..9747619 100644 --- a/lib/csu/mips/Makefile +++ b/lib/csu/mips/Makefile @@ -8,7 +8,13 @@ OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s @@ -37,8 +43,4 @@ Scrt1.s: crt1.c Scrt1.o: Scrt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile index bf4c7b1..9747619 100644 --- a/lib/csu/powerpc/Makefile +++ b/lib/csu/powerpc/Makefile @@ -8,7 +8,13 @@ OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR}/../common \ -I${.CURDIR}/../../libc/include -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s @@ -37,8 +43,4 @@ Scrt1.s: crt1.c Scrt1.o: Scrt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile index 1c93355..09b643e 100644 --- a/lib/csu/powerpc64/Makefile +++ b/lib/csu/powerpc64/Makefile @@ -16,7 +16,13 @@ CFLAGS+= -I${.CURDIR}/../common \ CC:= gcc COMPILER_TYPE:= gcc -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} CLEANFILES+= crt1.s gcrt1.s Scrt1.s @@ -45,8 +51,4 @@ Scrt1.s: crt1.c Scrt1.o: Scrt1.s ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/csu/sparc64/Makefile b/lib/csu/sparc64/Makefile index 7f8dd7a..0074cb9 100644 --- a/lib/csu/sparc64/Makefile +++ b/lib/csu/sparc64/Makefile @@ -7,7 +7,13 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../../libc/include -all: ${OBJS} +FILES= ${OBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY CLEANFILES= ${OBJS} @@ -17,8 +23,4 @@ gcrt1.o: crt1.c Scrt1.o: crt1.c ${CC} ${CFLAGS} -fPIC -DPIC -c -o Scrt1.o ${.ALLSRC} -realinstall: - ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${OBJS} ${DESTDIR}${LIBDIR} - .include <bsd.lib.mk> diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c index a8cef1c..0848476 100644 --- a/lib/libc/compat-43/sigcompat.c +++ b/lib/libc/compat-43/sigcompat.c @@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" int -sigvec(signo, sv, osv) - int signo; - struct sigvec *sv, *osv; +sigvec(int signo, struct sigvec *sv, struct sigvec *osv) { struct sigaction sa, osa; struct sigaction *sap, *osap; @@ -69,8 +67,7 @@ sigvec(signo, sv, osv) } int -sigsetmask(mask) - int mask; +sigsetmask(int mask) { sigset_t set, oset; int n; @@ -84,8 +81,7 @@ sigsetmask(mask) } int -sigblock(mask) - int mask; +sigblock(int mask) { sigset_t set, oset; int n; diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c index 42ffb1b..37adaf6 100644 --- a/lib/libc/db/hash/ndbm.c +++ b/lib/libc/db/hash/ndbm.c @@ -56,9 +56,7 @@ __FBSDID("$FreeBSD$"); * NULL on failure */ extern DBM * -dbm_open(file, flags, mode) - const char *file; - int flags, mode; +dbm_open(const char *file, int flags, int mode) { HASHINFO info; char path[MAXPATHLEN]; @@ -80,8 +78,7 @@ dbm_open(file, flags, mode) } extern void -dbm_close(db) - DBM *db; +dbm_close(DBM *db) { (void)(db->close)(db); } @@ -92,9 +89,7 @@ dbm_close(db) * NULL on failure */ extern datum -dbm_fetch(db, key) - DBM *db; - datum key; +dbm_fetch(DBM *db, datum key) { datum retdata; int status; @@ -118,8 +113,7 @@ dbm_fetch(db, key) * NULL on failure */ extern datum -dbm_firstkey(db) - DBM *db; +dbm_firstkey(DBM *db) { int status; datum retkey; @@ -139,8 +133,7 @@ dbm_firstkey(db) * NULL on failure */ extern datum -dbm_nextkey(db) - DBM *db; +dbm_nextkey(DBM *db) { int status; datum retkey; @@ -160,9 +153,7 @@ dbm_nextkey(db) * <0 failure */ extern int -dbm_delete(db, key) - DBM *db; - datum key; +dbm_delete(DBM *db, datum key) { int status; DBT dbtkey; @@ -183,10 +174,7 @@ dbm_delete(db, key) * 1 if DBM_INSERT and entry exists */ extern int -dbm_store(db, key, data, flags) - DBM *db; - datum key, data; - int flags; +dbm_store(DBM *db, datum key, datum data, int flags) { DBT dbtkey, dbtdata; @@ -199,8 +187,7 @@ dbm_store(db, key, data, flags) } extern int -dbm_error(db) - DBM *db; +dbm_error(DBM *db) { HTAB *hp; @@ -209,8 +196,7 @@ dbm_error(db) } extern int -dbm_clearerr(db) - DBM *db; +dbm_clearerr(DBM *db) { HTAB *hp; @@ -220,8 +206,7 @@ dbm_clearerr(db) } extern int -dbm_dirfno(db) - DBM *db; +dbm_dirfno(DBM *db) { return(((HTAB *)db->internal)->fp); } diff --git a/lib/libc/gen/clock.c b/lib/libc/gen/clock.c index b405cda..435e0f8 100644 --- a/lib/libc/gen/clock.c +++ b/lib/libc/gen/clock.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); + (r).tv_usec / (1000000 / CLOCKS_PER_SEC)) clock_t -clock() +clock(void) { struct rusage ru; diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c index 95a3a06..971d616 100644 --- a/lib/libc/gen/glob.c +++ b/lib/libc/gen/glob.c @@ -650,13 +650,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last, int err; char buf[MAXPATHLEN]; - /* - * The readdirfunc declaration can't be prototyped, because it is - * assigned, below, to two functions which are prototyped in glob.h - * and dirent.h as taking pointers to differently typed opaque - * structures. - */ - struct dirent *(*readdirfunc)(); + struct dirent *(*readdirfunc)(DIR *); if (pathend > pathend_last) return (GLOB_ABORTED); @@ -677,12 +671,14 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last, err = 0; - /* Search directory for matching names. */ + /* pglob->gl_readdir takes a void *, fix this manually */ if (pglob->gl_flags & GLOB_ALTDIRFUNC) - readdirfunc = pglob->gl_readdir; + readdirfunc = (struct dirent *(*)(DIR *))pglob->gl_readdir; else readdirfunc = readdir; - while ((dp = (*readdirfunc)(dirp))) { + + /* Search directory for matching names. */ + while ((dp = (*readdirfunc)(dirp)) != NULL) { char *sc; Char *dc; wchar_t wc; diff --git a/lib/libc/inet/inet_lnaof.c b/lib/libc/inet/inet_lnaof.c index 7cab894..274253f 100644 --- a/lib/libc/inet/inet_lnaof.c +++ b/lib/libc/inet/inet_lnaof.c @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); * number formats. */ in_addr_t -inet_lnaof(in) - struct in_addr in; +inet_lnaof(struct in_addr in) { in_addr_t i = ntohl(in.s_addr); diff --git a/lib/libc/inet/inet_makeaddr.c b/lib/libc/inet/inet_makeaddr.c index 04a37a0..bce0aa1 100644 --- a/lib/libc/inet/inet_makeaddr.c +++ b/lib/libc/inet/inet_makeaddr.c @@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$"); * building addresses stored in the ifnet structure. */ struct in_addr -inet_makeaddr(net, host) - in_addr_t net, host; +inet_makeaddr(in_addr_t net, in_addr_t host) { struct in_addr a; diff --git a/lib/libc/inet/inet_net_ntop.c b/lib/libc/inet/inet_net_ntop.c index da7af33..001a304 100644 --- a/lib/libc/inet/inet_net_ntop.c +++ b/lib/libc/inet/inet_net_ntop.c @@ -57,12 +57,7 @@ static char * inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, * Paul Vixie (ISC), July 1996 */ char * -inet_net_ntop(af, src, bits, dst, size) - int af; - const void *src; - int bits; - char *dst; - size_t size; +inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { case AF_INET: @@ -89,11 +84,7 @@ inet_net_ntop(af, src, bits, dst, size) * Paul Vixie (ISC), July 1996 */ static char * -inet_net_ntop_ipv4(src, bits, dst, size) - const u_char *src; - int bits; - char *dst; - size_t size; +inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) { char *odst = dst; char *t; diff --git a/lib/libc/inet/inet_neta.c b/lib/libc/inet/inet_neta.c index 01ad3be..06a1bdb 100644 --- a/lib/libc/inet/inet_neta.c +++ b/lib/libc/inet/inet_neta.c @@ -52,10 +52,7 @@ __FBSDID("$FreeBSD$"); * Paul Vixie (ISC), July 1996 */ char * -inet_neta(src, dst, size) - in_addr_t src; - char *dst; - size_t size; +inet_neta(in_addr_t src, char *dst, size_t size) { char *odst = dst; char *tp; diff --git a/lib/libc/inet/inet_netof.c b/lib/libc/inet/inet_netof.c index 8931c30..2335772 100644 --- a/lib/libc/inet/inet_netof.c +++ b/lib/libc/inet/inet_netof.c @@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$"); * address; handles class a/b/c network #'s. */ in_addr_t -inet_netof(in) - struct in_addr in; +inet_netof(struct in_addr in) { in_addr_t i = ntohl(in.s_addr); diff --git a/lib/libc/inet/inet_network.c b/lib/libc/inet/inet_network.c index 254db41..b5b9190 100644 --- a/lib/libc/inet/inet_network.c +++ b/lib/libc/inet/inet_network.c @@ -48,8 +48,7 @@ __FBSDID("$FreeBSD$"); * network numbers. */ in_addr_t -inet_network(cp) - const char *cp; +inet_network(const char *cp) { in_addr_t val, base, n; char c; diff --git a/lib/libc/locale/isctype.c b/lib/libc/locale/isctype.c index be1b091..2550534 100644 --- a/lib/libc/locale/isctype.c +++ b/lib/libc/locale/isctype.c @@ -45,184 +45,161 @@ __FBSDID("$FreeBSD$"); #undef digittoint int -digittoint(c) - int c; +digittoint(int c) { return (__sbmaskrune(c, 0xFF)); } #undef isalnum int -isalnum(c) - int c; +isalnum(int c) { return (__sbistype(c, _CTYPE_A|_CTYPE_D)); } #undef isalpha int -isalpha(c) - int c; +isalpha(int c) { return (__sbistype(c, _CTYPE_A)); } #undef isascii int -isascii(c) - int c; +isascii(int c) { return ((c & ~0x7F) == 0); } #undef isblank int -isblank(c) - int c; +isblank(int c) { return (__sbistype(c, _CTYPE_B)); } #undef iscntrl int -iscntrl(c) - int c; +iscntrl(int c) { return (__sbistype(c, _CTYPE_C)); } #undef isdigit int -isdigit(c) - int c; +isdigit(int c) { return (__isctype(c, _CTYPE_D)); } #undef isgraph int -isgraph(c) - int c; +isgraph(int c) { return (__sbistype(c, _CTYPE_G)); } #undef ishexnumber int -ishexnumber(c) - int c; +ishexnumber(int c) { return (__sbistype(c, _CTYPE_X)); } #undef isideogram int -isideogram(c) - int c; +isideogram(int c) { return (__sbistype(c, _CTYPE_I)); } #undef islower int -islower(c) - int c; +islower(int c) { return (__sbistype(c, _CTYPE_L)); } #undef isnumber int -isnumber(c) - int c; +isnumber(int c) { return (__sbistype(c, _CTYPE_D)); } #undef isphonogram int -isphonogram(c) - int c; +isphonogram(int c) { return (__sbistype(c, _CTYPE_Q)); } #undef isprint int -isprint(c) - int c; +isprint(int c) { return (__sbistype(c, _CTYPE_R)); } #undef ispunct int -ispunct(c) - int c; +ispunct(int c) { return (__sbistype(c, _CTYPE_P)); } #undef isrune int -isrune(c) - int c; +isrune(int c) { return (__sbistype(c, 0xFFFFFF00L)); } #undef isspace int -isspace(c) - int c; +isspace(int c) { return (__sbistype(c, _CTYPE_S)); } #undef isspecial int -isspecial(c) - int c; +isspecial(int c) { return (__sbistype(c, _CTYPE_T)); } #undef isupper int -isupper(c) - int c; +isupper(int c) { return (__sbistype(c, _CTYPE_U)); } #undef isxdigit int -isxdigit(c) - int c; +isxdigit(int c) { return (__isctype(c, _CTYPE_X)); } #undef toascii int -toascii(c) - int c; +toascii(int c) { return (c & 0x7F); } #undef tolower int -tolower(c) - int c; +tolower(int c) { return (__sbtolower(c)); } #undef toupper int -toupper(c) - int c; +toupper(int c) { return (__sbtoupper(c)); } diff --git a/lib/libc/locale/iswctype.c b/lib/libc/locale/iswctype.c index eaa1bf3..59d432c 100644 --- a/lib/libc/locale/iswctype.c +++ b/lib/libc/locale/iswctype.c @@ -42,168 +42,147 @@ __FBSDID("$FreeBSD$"); #undef iswalnum int -iswalnum(wc) - wint_t wc; +iswalnum(wint_t wc) { return (__istype(wc, _CTYPE_A|_CTYPE_D)); } #undef iswalpha int -iswalpha(wc) - wint_t wc; +iswalpha(wint_t wc) { return (__istype(wc, _CTYPE_A)); } #undef iswascii int -iswascii(wc) - wint_t wc; +iswascii(wint_t wc) { return ((wc & ~0x7F) == 0); } #undef iswblank int -iswblank(wc) - wint_t wc; +iswblank(wint_t wc) { return (__istype(wc, _CTYPE_B)); } #undef iswcntrl int -iswcntrl(wc) - wint_t wc; +iswcntrl(wint_t wc) { return (__istype(wc, _CTYPE_C)); } #undef iswdigit int -iswdigit(wc) - wint_t wc; +iswdigit(wint_t wc) { return (__isctype(wc, _CTYPE_D)); } #undef iswgraph int -iswgraph(wc) - wint_t wc; +iswgraph(wint_t wc) { return (__istype(wc, _CTYPE_G)); } #undef iswhexnumber int -iswhexnumber(wc) - wint_t wc; +iswhexnumber(wint_t wc) { return (__istype(wc, _CTYPE_X)); } #undef iswideogram int -iswideogram(wc) - wint_t wc; +iswideogram(wint_t wc) { return (__istype(wc, _CTYPE_I)); } #undef iswlower int -iswlower(wc) - wint_t wc; +iswlower(wint_t wc) { return (__istype(wc, _CTYPE_L)); } #undef iswnumber int -iswnumber(wc) - wint_t wc; +iswnumber(wint_t wc) { return (__istype(wc, _CTYPE_D)); } #undef iswphonogram int -iswphonogram(wc) - wint_t wc; +iswphonogram(wint_t wc) { return (__istype(wc, _CTYPE_Q)); } #undef iswprint int -iswprint(wc) - wint_t wc; +iswprint(wint_t wc) { return (__istype(wc, _CTYPE_R)); } #undef iswpunct int -iswpunct(wc) - wint_t wc; +iswpunct(wint_t wc) { return (__istype(wc, _CTYPE_P)); } #undef iswrune int -iswrune(wc) - wint_t wc; +iswrune(wint_t wc) { return (__istype(wc, 0xFFFFFF00L)); } #undef iswspace int -iswspace(wc) - wint_t wc; +iswspace(wint_t wc) { return (__istype(wc, _CTYPE_S)); } #undef iswspecial int -iswspecial(wc) - wint_t wc; +iswspecial(wint_t wc) { return (__istype(wc, _CTYPE_T)); } #undef iswupper int -iswupper(wc) - wint_t wc; +iswupper(wint_t wc) { return (__istype(wc, _CTYPE_U)); } #undef iswxdigit int -iswxdigit(wc) - wint_t wc; +iswxdigit(wint_t wc) { return (__isctype(wc, _CTYPE_X)); } #undef towlower wint_t -towlower(wc) - wint_t wc; +towlower(wint_t wc) { return (__tolower(wc)); } #undef towupper wint_t -towupper(wc) - wint_t wc; +towupper(wint_t wc) { return (__toupper(wc)); } diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index 0322af2..13ff25b 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -98,9 +98,7 @@ static char *loadlocale(int); const char *__get_locale_env(int); char * -setlocale(category, locale) - int category; - const char *locale; +setlocale(int category, const char *locale) { int i, j, len, saverr; const char *env, *r; @@ -209,7 +207,7 @@ setlocale(category, locale) } static char * -currentlocale() +currentlocale(void) { int i; @@ -228,8 +226,7 @@ currentlocale() } static char * -loadlocale(category) - int category; +loadlocale(int category) { char *new = new_categories[category]; char *old = current_categories[category]; @@ -286,8 +283,7 @@ loadlocale(category) } const char * -__get_locale_env(category) - int category; +__get_locale_env(int category) { const char *env; diff --git a/lib/libc/locale/tolower.c b/lib/libc/locale/tolower.c index f2eb483..c74791d 100644 --- a/lib/libc/locale/tolower.c +++ b/lib/libc/locale/tolower.c @@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$"); #include "mblocal.h" __ct_rune_t -___tolower_l(c, l) - __ct_rune_t c; - locale_t l; +___tolower_l(__ct_rune_t c, locale_t l) { size_t lim; FIX_LOCALE(l); @@ -72,8 +70,7 @@ ___tolower_l(c, l) return(c); } __ct_rune_t -___tolower(c) - __ct_rune_t c; +___tolower(__ct_rune_t c) { return ___tolower_l(c, __get_locale()); } diff --git a/lib/libc/locale/toupper.c b/lib/libc/locale/toupper.c index 704ac3a..2c5ec86 100644 --- a/lib/libc/locale/toupper.c +++ b/lib/libc/locale/toupper.c @@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$"); #include "mblocal.h" __ct_rune_t -___toupper_l(c, l) - __ct_rune_t c; - locale_t l; +___toupper_l(__ct_rune_t c, locale_t l) { size_t lim; FIX_LOCALE(l); @@ -74,8 +72,7 @@ ___toupper_l(c, l) return(c); } __ct_rune_t -___toupper(c) - __ct_rune_t c; +___toupper(__ct_rune_t c) { return ___toupper_l(c, __get_locale()); } diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c index f301c88..ac93abe 100644 --- a/lib/libc/net/gethostbydns.c +++ b/lib/libc/net/gethostbydns.c @@ -107,10 +107,7 @@ int _dns_ttl_; #ifdef DEBUG static void -dprintf(msg, num, res) - char *msg; - int num; - res_state res; +dprintf(char *msg, int num, res_state res) { if (res->options & RES_DEBUG) { int save = errno; @@ -769,7 +766,7 @@ _sethostdnsent(int stayopen) } void -_endhostdnsent() +_endhostdnsent(void) { res_state statp; diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c index 79e40a5..6667a82 100644 --- a/lib/libc/net/getnetbydns.c +++ b/lib/libc/net/getnetbydns.c @@ -455,7 +455,7 @@ _setnetdnsent(int stayopen) } void -_endnetdnsent() +_endnetdnsent(void) { res_state statp; diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c index 005de98..6a68ef5 100644 --- a/lib/libc/net/getservent.c +++ b/lib/libc/net/getservent.c @@ -1241,7 +1241,7 @@ setservent(int stayopen) } void -endservent() +endservent(void) { #ifdef NS_CACHING static const nss_cache_info cache_info = NS_MP_CACHE_INFO_INITIALIZER( @@ -1362,7 +1362,7 @@ getservbyport(int port, const char *proto) } struct servent * -getservent() +getservent(void) { struct key key; diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c index 5be6e74..2f7222b 100644 --- a/lib/libc/net/linkaddr.c +++ b/lib/libc/net/linkaddr.c @@ -50,9 +50,7 @@ __FBSDID("$FreeBSD$"); #define LETTER (4*3) void -link_addr(addr, sdl) - const char *addr; - struct sockaddr_dl *sdl; +link_addr(const char *addr, struct sockaddr_dl *sdl) { char *cp = sdl->sdl_data; char *cplim = sdl->sdl_len + (char *)sdl; @@ -121,8 +119,7 @@ link_addr(addr, sdl) static const char hexlist[] = "0123456789abcdef"; char * -link_ntoa(sdl) - const struct sockaddr_dl *sdl; +link_ntoa(const struct sockaddr_dl *sdl) { static char obuf[64]; char *out = obuf; diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l index 3983fa2..c7a95f6 100644 --- a/lib/libc/net/nslexer.l +++ b/lib/libc/net/nslexer.l @@ -97,14 +97,13 @@ STRING [a-zA-Z][a-zA-Z0-9_]* #undef _nsyywrap int -_nsyywrap() +_nsyywrap(void) { return 1; } /* _nsyywrap */ void -_nsyyerror(msg) - const char *msg; +_nsyyerror(const char *msg) { syslog(LOG_ERR, "NSSWITCH(nslexer): %s line %d: %s at '%s'", diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y index c1d8424..7d2f6e2 100644 --- a/lib/libc/net/nsparser.y +++ b/lib/libc/net/nsparser.y @@ -145,8 +145,7 @@ Action %% static void -_nsaddsrctomap(elem) - const char *elem; +_nsaddsrctomap(const char *elem) { int i, lineno; extern int _nsyylineno; diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 1ba9888..c7ca870 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -73,22 +73,15 @@ static int __icheckhost(const struct sockaddr *, socklen_t, const char *); char paddr[NI_MAXHOST]; int -rcmd(ahost, rport, locuser, remuser, cmd, fd2p) - char **ahost; - u_short rport; - const char *locuser, *remuser, *cmd; - int *fd2p; +rcmd(char **ahost, int rport, const char *locuser, const char *remuser, + const char *cmd, int *fd2p) { return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); } int -rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) - char **ahost; - u_short rport; - const char *locuser, *remuser, *cmd; - int *fd2p; - int af; +rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser, + const char *cmd, int *fd2p, int af) { struct addrinfo hints, *res, *ai; struct sockaddr_storage from; @@ -321,15 +314,13 @@ bad: } int -rresvport(port) - int *port; +rresvport(int *port) { return rresvport_af(port, AF_INET); } int -rresvport_af(alport, family) - int *alport, family; +rresvport_af(int *alport, int family) { int s; struct sockaddr_storage ss; @@ -380,9 +371,7 @@ int __check_rhosts_file = 1; char *__rcmd_errstr; int -ruserok(rhost, superuser, ruser, luser) - const char *rhost, *ruser, *luser; - int superuser; +ruserok(const char *rhost, int superuser, const char *ruser, const char *luser) { struct addrinfo hints, *res, *r; int error; @@ -415,10 +404,7 @@ ruserok(rhost, superuser, ruser, luser) * Returns 0 if ok, -1 if not ok. */ int -iruserok(raddr, superuser, ruser, luser) - unsigned long raddr; - int superuser; - const char *ruser, *luser; +iruserok(unsigned long raddr, int superuser, const char *ruser, const char *luser) { struct sockaddr_in sin; @@ -436,11 +422,8 @@ iruserok(raddr, superuser, ruser, luser) * Returns 0 if ok, -1 if not ok. */ int -iruserok_sa(ra, rlen, superuser, ruser, luser) - const void *ra; - int rlen; - int superuser; - const char *ruser, *luser; +iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser, + const char *luser) { char *cp; struct stat sbuf; @@ -520,10 +503,7 @@ again: * Returns 0 if ok, -1 if not ok. */ int -__ivaliduser(hostf, raddr, luser, ruser) - FILE *hostf; - u_int32_t raddr; - const char *luser, *ruser; +__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser) { struct sockaddr_in sin; @@ -541,11 +521,8 @@ __ivaliduser(hostf, raddr, luser, ruser) * XXX obsolete API. */ int -__ivaliduser_af(hostf, raddr, luser, ruser, af, len) - FILE *hostf; - const void *raddr; - const char *luser, *ruser; - int af, len; +__ivaliduser_af(FILE *hostf, const void *raddr, const char *luser, + const char *ruser, int af, int len) { struct sockaddr *sa = NULL; struct sockaddr_in *sin = NULL; @@ -584,11 +561,8 @@ __ivaliduser_af(hostf, raddr, luser, ruser, af, len) } int -__ivaliduser_sa(hostf, raddr, salen, luser, ruser) - FILE *hostf; - const struct sockaddr *raddr; - socklen_t salen; - const char *luser, *ruser; +__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen, + const char *luser, const char *ruser) { char *user, *p; int ch; @@ -707,10 +681,7 @@ __ivaliduser_sa(hostf, raddr, salen, luser, ruser) * Returns "true" if match, 0 if no match. */ static int -__icheckhost(raddr, salen, lhost) - const struct sockaddr *raddr; - socklen_t salen; - const char *lhost; +__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost) { struct sockaddr_in sin; struct sockaddr_in6 *sin6; diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c index 6a584ca..68d3ce5 100644 --- a/lib/libc/net/recv.c +++ b/lib/libc/net/recv.c @@ -40,10 +40,7 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> ssize_t -recv(s, buf, len, flags) - int s, flags; - size_t len; - void *buf; +recv(int s, void *buf, size_t len, int flags) { /* * POSIX says recv() shall be a cancellation point, so call the diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c index f92fdec..3b2ebba 100644 --- a/lib/libc/net/rthdr.c +++ b/lib/libc/net/rthdr.c @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); */ size_t -inet6_rthdr_space(type, seg) - int type, seg; +inet6_rthdr_space(int type, int seg) { switch (type) { case IPV6_RTHDR_TYPE_0: @@ -67,9 +66,7 @@ inet6_rthdr_space(type, seg) } struct cmsghdr * -inet6_rthdr_init(bp, type) - void *bp; - int type; +inet6_rthdr_init(void *bp, int type) { struct cmsghdr *ch = (struct cmsghdr *)bp; struct ip6_rthdr *rthdr; @@ -98,10 +95,7 @@ inet6_rthdr_init(bp, type) /* ARGSUSED */ int -inet6_rthdr_add(cmsg, addr, flags) - struct cmsghdr *cmsg; - const struct in6_addr *addr; - u_int flags; +inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, u_int flags) { struct ip6_rthdr *rthdr; @@ -143,9 +137,7 @@ inet6_rthdr_add(cmsg, addr, flags) /* ARGSUSED */ int -inet6_rthdr_lasthop(cmsg, flags) - struct cmsghdr *cmsg; - unsigned int flags; +inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags) { struct ip6_rthdr *rthdr; @@ -183,9 +175,7 @@ inet6_rthdr_lasthop(cmsg, flags) #if 0 int -inet6_rthdr_reverse(in, out) - const struct cmsghdr *in; - struct cmsghdr *out; +inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out) { return (-1); @@ -193,8 +183,7 @@ inet6_rthdr_reverse(in, out) #endif int -inet6_rthdr_segments(cmsg) - const struct cmsghdr *cmsg; +inet6_rthdr_segments(const struct cmsghdr *cmsg) { struct ip6_rthdr *rthdr; @@ -217,9 +206,7 @@ inet6_rthdr_segments(cmsg) } struct in6_addr * -inet6_rthdr_getaddr(cmsg, idx) - struct cmsghdr *cmsg; - int idx; +inet6_rthdr_getaddr(struct cmsghdr *cmsg, int idx) { struct ip6_rthdr *rthdr; @@ -249,9 +236,7 @@ inet6_rthdr_getaddr(cmsg, idx) } int -inet6_rthdr_getflags(cmsg, idx) - const struct cmsghdr *cmsg; - int idx; +inet6_rthdr_getflags(const struct cmsghdr *cmsg, int idx) { struct ip6_rthdr *rthdr; diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c index c44f4b9..ff98436 100644 --- a/lib/libc/net/send.c +++ b/lib/libc/net/send.c @@ -40,10 +40,7 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> ssize_t -send(s, msg, len, flags) - int s, flags; - size_t len; - const void *msg; +send(int s, const void *msg, size_t len, int flags) { /* * POSIX says send() shall be a cancellation point, so call the diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 8981011..838ebdd 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -127,13 +127,8 @@ strftime(char * __restrict s, size_t maxsize, const char * __restrict format, } static char * -_fmt(format, t, pt, ptlim, warnp, loc) -const char * format; -const struct tm * const t; -char * pt; -const char * const ptlim; -int * warnp; -locale_t loc; +_fmt(const char *format, const struct tm * const t, char *pt, + const char * const ptlim, int *warnp, locale_t loc) { int Ealternative, Oalternative, PadIndex; struct lc_time_T *tptr = __get_current_time_locale(loc); @@ -592,12 +587,8 @@ label: } static char * -_conv(n, format, pt, ptlim, loc) -const int n; -const char * const format; -char * const pt; -const char * const ptlim; -locale_t loc; +_conv(const int n, const char * const format, char * const pt, + const char * const ptlim, locale_t loc) { char buf[INT_STRLEN_MAXIMUM(int) + 1]; @@ -606,10 +597,7 @@ locale_t loc; } static char * -_add(str, pt, ptlim) -const char * str; -char * pt; -const char * const ptlim; +_add(const char *str, char *pt, const char * const ptlim) { while (pt < ptlim && (*pt = *str++) != '\0') ++pt; @@ -625,14 +613,8 @@ const char * const ptlim; */ static char * -_yconv(a, b, convert_top, convert_yy, pt, ptlim, loc) -const int a; -const int b; -const int convert_top; -const int convert_yy; -char * pt; -const char * const ptlim; -locale_t loc; +_yconv(const int a, const int b, const int convert_top, const int convert_yy, + char *pt, const char * const ptlim, locale_t loc) { register int lead; register int trail; diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index fad970c..a4414fa 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -90,8 +90,6 @@ ASM+=$(_asm) .endif .endfor -OBJS+= ${ASM} ${PSEUDO} - SASM= ${ASM:S/.o/.S/} SPSEUDO= ${PSEUDO:S/.o/.S/} diff --git a/lib/libc/xdr/xdr_float.c b/lib/libc/xdr/xdr_float.c index fc024fc..63ecd03 100644 --- a/lib/libc/xdr/xdr_float.c +++ b/lib/libc/xdr/xdr_float.c @@ -102,9 +102,7 @@ static struct sgl_limits { #endif /* vax */ bool_t -xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; +xdr_float(XDR *xdrs, float *fp) { #ifndef IEEEFP struct ieee_single is; diff --git a/lib/libpam/Makefile.inc b/lib/libpam/Makefile.inc index d2d1d42..59a8ced 100644 --- a/lib/libpam/Makefile.inc +++ b/lib/libpam/Makefile.inc @@ -27,7 +27,6 @@ CFLAGS+= -DOPENPAM_DEBUG SHLIB_MAJOR= 5 -PAM_MOD_DIR= ${LIBDIR} STATIC_CFLAGS+= -DOPENPAM_STATIC_MODULES diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile index c8f13c4..1dc977f 100644 --- a/lib/libpam/libpam/Makefile +++ b/lib/libpam/libpam/Makefile @@ -155,7 +155,6 @@ MLINKS= pam.conf.5 pam.d.5 CSTD?= c99 CFLAGS+= -I${.CURDIR} -I${OPENPAM}/include CFLAGS+= -DLIB_MAJ=${SHLIB_MAJOR} -CFLAGS+= -DOPENPAM_MODULES_DIRECTORY='"${PAM_MOD_DIR:C/\/*$//}/"' CFLAGS+= -DHAVE_DLFUNC=1 CFLAGS+= -DHAVE_FDLOPEN=1 CFLAGS+= -DHAVE_FPURGE=1 diff --git a/share/man/man4/rsu.4 b/share/man/man4/rsu.4 index f9a8c9e..2bd2f94 100644 --- a/share/man/man4/rsu.4 +++ b/share/man/man4/rsu.4 @@ -178,5 +178,4 @@ and ported by .Sh CAVEATS The .Nm -driver does not support any of the 802.11n capabilities offered by the -adapters. +driver only supports 1T1R 802.11n operation. diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 268361a..2a10157 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1641,7 +1641,6 @@ MLINKS+=timeout.9 callout.9 \ timeout.9 callout_active.9 \ timeout.9 callout_deactivate.9 \ timeout.9 callout_drain.9 \ - timeout.9 callout_drain_async.9 \ timeout.9 callout_handle_init.9 \ timeout.9 callout_init.9 \ timeout.9 callout_init_mtx.9 \ diff --git a/share/man/man9/timeout.9 b/share/man/man9/timeout.9 index b179856..a0dc003 100644 --- a/share/man/man9/timeout.9 +++ b/share/man/man9/timeout.9 @@ -36,7 +36,6 @@ .Nm callout_active , .Nm callout_deactivate , .Nm callout_drain , -.Nm callout_drain_async , .Nm callout_handle_init , .Nm callout_init , .Nm callout_init_mtx , @@ -71,8 +70,6 @@ typedef void timeout_t (void *); .Fn callout_deactivate "struct callout *c" .Ft int .Fn callout_drain "struct callout *c" -.Ft int -.Fn callout_drain_async "struct callout *c" "callout_func_t *fn" "void *arg" .Ft void .Fn callout_handle_init "struct callout_handle *handle" .Bd -literal @@ -267,24 +264,6 @@ fully stopped before .Fn callout_drain returns. .Pp -The function -.Fn callout_drain_async -is non-blocking and works the same as the -.Fn callout_stop -function. -When this function returns non-zero, do not call it again until the callback function given by -.Fa fn -has been called with argument -.Fa arg . -Only one of -.Fn callout_drain -or -.Fn callout_drain_async -should be called at a time to drain a callout. -If this function returns zero, it is safe to free the callout structure pointed to by the -.Fa c -argument immediately. -.Pp The .Fn callout_reset and diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 4e1cb2d..ca765bb 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -162,7 +162,7 @@ LDFLAGS+= -Wl,--version-script=${VERSION_MAP} .if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) OBJS+= ${SRCS:N*.h:R:S/$/.o/} -NOPATH_FILES+= ${OBJS} +CLEANFILES+= ${OBJS} ${STATICOBJS} .endif .if defined(LIB) && !empty(LIB) @@ -180,7 +180,7 @@ lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS} .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) _LIBS+= lib${LIB_PRIVATE}${LIB}_p.a POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po} -NOPATH_FILES+= ${POBJS} +CLEANFILES+= ${POBJS} lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} @${ECHO} building profiled ${LIB} library @@ -192,7 +192,7 @@ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS} .if defined(SHLIB_NAME) || \ defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) SOBJS+= ${OBJS:.o=.So} -NOPATH_FILES+= ${SOBJS} +CLEANFILES+= ${SOBJS} .endif .if defined(SHLIB_NAME) @@ -238,7 +238,9 @@ ${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT} ${.ALLSRC} > ${.TARGET} ${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld +CLEANFILES+= ${SHLIB_LINK:R}.ld .endif +CLEANFILES+= ${SHLIB_LINK} .endif ${SHLIB_NAME_FULL}: ${SOBJS} @@ -279,7 +281,7 @@ lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS} LINTLIB= llib-l${LIB}.ln _LIBS+= ${LINTLIB} LINTOBJS+= ${SRCS:M*.c:.c=.ln} -NOPATH_FILES+= ${LINTOBJS} +CLEANFILES+= ${LINTOBJS} ${LINTLIB}: ${LINTOBJS} @${ECHO} building lint library ${.TARGET} @@ -292,7 +294,10 @@ ${LINTLIB}: ${LINTOBJS} .if defined(_SKIP_BUILD) all: .else +.if defined(_LIBS) && !empty(_LIBS) all: ${_LIBS} +CLEANFILES+= ${_LIBS} +.endif .if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) all: _manpages @@ -423,49 +428,6 @@ ${_S:R}.So: ${_S} .endif .endif -.if !target(clean) -clean: -.if defined(CLEANFILES) && !empty(CLEANFILES) - rm -f ${CLEANFILES} -.endif -.if defined(LIB) && !empty(LIB) - rm -f a.out ${OBJS} ${OBJS:S/$/.tmp/} ${STATICOBJS} -.endif -.if !defined(INTERNALLIB) -.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) - rm -f ${POBJS} ${POBJS:S/$/.tmp/} -.endif -.if defined(SHLIB_NAME) || \ - defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) - rm -f ${SOBJS} ${SOBJS:.So=.so} ${SOBJS:S/$/.tmp/} -.endif -.if defined(SHLIB_NAME) -.if defined(SHLIB_LINK) -.if defined(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) - rm -f lib${LIB}.ld -.endif - rm -f ${SHLIB_LINK} -.endif -.endif # defined(SHLIB_NAME) -.if defined(WANT_LINT) && defined(LIB) && !empty(LIB) - rm -f ${LINTOBJS} -.endif -.endif # !defined(INTERNALLIB) -.if defined(_LIBS) && !empty(_LIBS) - rm -f ${_LIBS} -.endif -.if defined(CLEANDIRS) && !empty(CLEANDIRS) - rm -rf ${CLEANDIRS} -.endif -.if !empty(VERSION_DEF) && !empty(SYMBOL_MAPS) - rm -f ${VERSION_MAP} -.endif -.endif - -.if !empty(_LIBS) -NOPATH_FILES+= ${_LIBS} -.endif - .include <bsd.obj.mk> .include <bsd.sys.mk> diff --git a/sys/arm/allwinner/a20/a20_if_dwc.c b/sys/arm/allwinner/a20/a20_if_dwc.c new file mode 100644 index 0000000..88981ef --- /dev/null +++ b/sys/arm/allwinner/a20/a20_if_dwc.c @@ -0,0 +1,107 @@ +/*- + * Copyright (c) 2015 Luiz Otavio O Souza <loos@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/bus.h> +#include <sys/kernel.h> +#include <sys/module.h> + +#include <machine/bus.h> + +#include <dev/dwc/if_dwc.h> +#include <dev/dwc/if_dwcvar.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> + +#include <arm/allwinner/a10_clk.h> +#include <arm/allwinner/a10_gpio.h> + +#include "if_dwc_if.h" + +static int +a20_if_dwc_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + if (!ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-gmac")) + return (ENXIO); + device_set_desc(dev, "A20 Gigabit Ethernet Controller"); + + return (BUS_PROBE_DEFAULT); +} + +static int +a20_if_dwc_init(device_t dev) +{ + + /* Activate GMAC clock and set the pin mux to rgmii. */ + if (a10_clk_gmac_activate(ofw_bus_get_node(dev)) != 0 || + a10_gpio_ethernet_activate(A10_GPIO_FUNC_RGMII)) { + device_printf(dev, "could not activate gmac module\n"); + return (ENXIO); + } + + return (0); +} + +static int +a20_if_dwc_mac_type(device_t dev) +{ + + return (DWC_GMAC_ALT_DESC); +} + +static int +a20_if_dwc_mii_clk(device_t dev) +{ + + return (GMAC_MII_CLK_150_250M_DIV102); +} + +static device_method_t a20_dwc_methods[] = { + DEVMETHOD(device_probe, a20_if_dwc_probe), + + DEVMETHOD(if_dwc_init, a20_if_dwc_init), + DEVMETHOD(if_dwc_mac_type, a20_if_dwc_mac_type), + DEVMETHOD(if_dwc_mii_clk, a20_if_dwc_mii_clk), + + DEVMETHOD_END +}; + +static devclass_t a20_dwc_devclass; + +extern driver_t dwc_driver; + +DEFINE_CLASS_1(dwc, a20_dwc_driver, a20_dwc_methods, sizeof(struct dwc_softc), + dwc_driver); +DRIVER_MODULE(a20_dwc, simplebus, a20_dwc_driver, a20_dwc_devclass, 0, 0); + +MODULE_DEPEND(a20_dwc, dwc, 1, 1, 1); diff --git a/sys/arm/allwinner/a20/files.a20 b/sys/arm/allwinner/a20/files.a20 index 25fd880..fe475b6 100644 --- a/sys/arm/allwinner/a20/files.a20 +++ b/sys/arm/allwinner/a20/files.a20 @@ -1,3 +1,4 @@ # $FreeBSD$ arm/allwinner/a20/a20_mp.c optional smp +arm/allwinner/a20/a20_if_dwc.c optional dwc diff --git a/sys/arm/conf/A20 b/sys/arm/conf/A20 index 00cdb8f..3bac455 100644 --- a/sys/arm/conf/A20 +++ b/sys/arm/conf/A20 @@ -47,7 +47,7 @@ options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed #options BOOTP_NFSROOT #options BOOTP_COMPAT #options BOOTP_NFSV3 -#options BOOTP_WIRED_TO=cpsw0 +#options BOOTP_WIRED_TO=dwc0 # Boot device is 2nd slice on MMC/SD card options ROOTDEVNAME=\"ufs:/dev/da0s2\" @@ -102,7 +102,8 @@ device ether device mii device bpf -device emac +#device emac # 10/100 integrated EMAC controller +device dwc # 10/100/1000 integrated GMAC controller # USB ethernet support, requires miibus device miibus diff --git a/sys/boot/fdt/dts/arm/cubieboard2.dts b/sys/boot/fdt/dts/arm/cubieboard2.dts index 700952a..480df66 100644 --- a/sys/boot/fdt/dts/arm/cubieboard2.dts +++ b/sys/boot/fdt/dts/arm/cubieboard2.dts @@ -67,6 +67,10 @@ status = "okay"; }; + gmac@01c50000 { + status = "okay"; + }; + ahci: sata@01c18000 { status = "okay"; }; diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 79a1fb5..87f5787 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -1611,6 +1611,16 @@ restart: if (cs2 != cs && cs2->cs_tasks_aborted == false && cs->cs_target == cs2->cs_target && strcmp(cs->cs_initiator_id, cs2->cs_initiator_id) == 0) { + if (strcmp(cs->cs_initiator_addr, + cs2->cs_initiator_addr) != 0) { + CFISCSI_SESSION_WARN(cs2, + "session reinstatement from " + "different address %s", + cs->cs_initiator_addr); + } else { + CFISCSI_SESSION_DEBUG(cs2, + "session reinstatement"); + } cfiscsi_session_terminate(cs2); mtx_unlock(&softc->lock); pause("cfiscsi_reinstate", 1); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index 6d1792c..42c001a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -1485,6 +1485,13 @@ arc_hdr_realloc(arc_buf_hdr_t *hdr, kmem_cache_t *old, kmem_cache_t *new) VERIFY(!HDR_L2_WRITING(hdr)); VERIFY3P(hdr->b_l1hdr.b_tmp_cdata, ==, NULL); +#ifdef ZFS_DEBUG + if (hdr->b_l1hdr.b_thawed != NULL) { + kmem_free(hdr->b_l1hdr.b_thawed, 1); + hdr->b_l1hdr.b_thawed = NULL; + } +#endif + nhdr->b_flags &= ~ARC_FLAG_HAS_L1HDR; } /* diff --git a/sys/conf/files b/sys/conf/files index df8233f..4f13269 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1881,6 +1881,7 @@ dev/ixgbe/ixgbe_dcb_82599.c optional ix inet | ixv inet \ dev/jme/if_jme.c optional jme pci dev/joy/joy.c optional joy dev/joy/joy_isa.c optional joy isa +dev/kbd/kbd.c optional atkbd | pckbd | sc | ukbd | vt dev/kbdmux/kbdmux.c optional kbdmux dev/ksyms/ksyms.c optional ksyms dev/le/am7990.c optional le diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 3def78f..0788b46 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -275,7 +275,6 @@ dev/hyperv/vmbus/hv_connection.c optional hyperv dev/hyperv/vmbus/hv_hv.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv -dev/kbd/kbd.c optional atkbd | sc | ukbd | vt dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb dev/ntb/ntb_hw/ntb_hw.c optional if_ntb | ntb_hw diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 8f03809..84267a0 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -90,7 +90,6 @@ dev/fb/fb.c optional sc dev/fdt/fdt_arm_platform.c optional platform fdt dev/hwpmc/hwpmc_arm.c optional hwpmc dev/hwpmc/hwpmc_armv7.c optional hwpmc armv6 -dev/kbd/kbd.c optional sc | vt dev/psci/psci.c optional psci dev/psci/psci_arm.S optional psci dev/syscons/scgfbrndr.c optional sc diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index bcbcf00..399a35e 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -59,7 +59,6 @@ dev/acpica/acpi_if.m optional acpi dev/fdt/fdt_arm64.c optional fdt dev/hwpmc/hwpmc_arm64.c optional hwpmc dev/hwpmc/hwpmc_arm64_md.c optional hwpmc -dev/kbd/kbd.c optional atkbd | sc | ukbd | vt dev/mmc/host/dwmmc.c optional dwmmc dev/mmc/host/dwmmc_hisi.c optional dwmmc soc_hisi_hi6220 dev/ofw/ofw_cpu.c optional fdt diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 1fae3a5..da2097b 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -265,7 +265,6 @@ dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux -dev/kbd/kbd.c optional atkbd | sc | ukbd | vt dev/le/if_le_isa.c optional le isa dev/mse/mse.c optional mse dev/mse/mse_isa.c optional mse isa diff --git a/sys/conf/files.mips b/sys/conf/files.mips index f476307..76ad371 100644 --- a/sys/conf/files.mips +++ b/sys/conf/files.mips @@ -71,7 +71,6 @@ dev/cfe/cfe_env.c optional cfe_env # syscons support dev/fb/fb.c optional sc -dev/kbd/kbd.c optional sc | vt dev/syscons/scgfbrndr.c optional sc dev/syscons/scterm-teken.c optional sc dev/syscons/scvtb.c optional sc diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98 index ee6cf71..78f85ba 100644 --- a/sys/conf/files.pc98 +++ b/sys/conf/files.pc98 @@ -127,7 +127,6 @@ dev/hwpmc/hwpmc_ppro.c optional hwpmc dev/hwpmc/hwpmc_tsc.c optional hwpmc dev/hwpmc/hwpmc_x86.c optional hwpmc dev/io/iodev.c optional io -dev/kbd/kbd.c optional pckbd | sc | ukbd dev/le/if_le_cbus.c optional le isa dev/mse/mse.c optional mse dev/mse/mse_cbus.c optional mse isa diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index d647acc..be17b6e 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -44,7 +44,6 @@ dev/iicbus/adt746x.c optional adt746x powermac dev/iicbus/ds1631.c optional ds1631 powermac dev/iicbus/ds1775.c optional ds1775 powermac dev/iicbus/max6690.c optional max6690 powermac -dev/kbd/kbd.c optional sc | vt dev/nand/nfc_fsl.c optional nand mpc85xx dev/nand/nfc_rb.c optional nand mpc85xx # ofw can be either aim or fdt: fdt case handled in files. aim only powerpc specific. diff --git a/sys/conf/files.sparc64 b/sys/conf/files.sparc64 index 78f0428..0a0b721 100644 --- a/sys/conf/files.sparc64 +++ b/sys/conf/files.sparc64 @@ -40,7 +40,6 @@ dev/fb/fb.c optional sc dev/fb/gallant12x22.c optional sc dev/fb/machfb.c optional machfb sc dev/hwpmc/hwpmc_sparc64.c optional hwpmc -dev/kbd/kbd.c optional atkbd | sc | ukbd | vt dev/le/if_le_lebuffer.c optional le sbus dev/le/if_le_ledma.c optional le sbus dev/le/lebuffer_sbus.c optional le sbus diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 374e1d0..770badd 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -4127,7 +4127,6 @@ ath_txq_init(struct ath_softc *sc, struct ath_txq *txq, int qnum) static struct ath_txq * ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct ath_hal *ah = sc->sc_ah; HAL_TXQ_INFO qi; int qnum; @@ -4164,10 +4163,10 @@ ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) */ return NULL; } - if (qnum >= N(sc->sc_txq)) { + if (qnum >= nitems(sc->sc_txq)) { device_printf(sc->sc_dev, "hal qnum %u out of range, max %zu!\n", - qnum, N(sc->sc_txq)); + qnum, nitems(sc->sc_txq)); ath_hal_releasetxqueue(ah, qnum); return NULL; } @@ -4176,7 +4175,6 @@ ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) sc->sc_txqsetup |= 1<<qnum; } return &sc->sc_txq[qnum]; -#undef N } /* @@ -4191,12 +4189,11 @@ ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) static int ath_tx_setup(struct ath_softc *sc, int ac, int haltype) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct ath_txq *txq; - if (ac >= N(sc->sc_ac2q)) { + if (ac >= nitems(sc->sc_ac2q)) { device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", - ac, N(sc->sc_ac2q)); + ac, nitems(sc->sc_ac2q)); return 0; } txq = ath_txq_setup(sc, HAL_TX_QUEUE_DATA, haltype); @@ -4206,7 +4203,6 @@ ath_tx_setup(struct ath_softc *sc, int ac, int haltype) return 1; } else return 0; -#undef N } /* @@ -4216,7 +4212,6 @@ static int ath_txq_update(struct ath_softc *sc, int ac) { #define ATH_EXPONENT_TO_VALUE(v) ((1<<v)-1) -#define ATH_TXOP_TO_US(v) (v<<5) struct ieee80211com *ic = &sc->sc_ic; struct ath_txq *txq = sc->sc_ac2q[ac]; struct wmeParams *wmep = &ic->ic_wme.wme_chanParams.cap_wmeParams[ac]; @@ -4262,7 +4257,7 @@ ath_txq_update(struct ath_softc *sc, int ac) qi.tqi_cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin); qi.tqi_cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax); qi.tqi_readyTime = 0; - qi.tqi_burstTime = ATH_TXOP_TO_US(wmep->wmep_txopLimit); + qi.tqi_burstTime = IEEE80211_TXOP_TO_US(wmep->wmep_txopLimit); #ifdef IEEE80211_SUPPORT_TDMA } #endif @@ -4280,7 +4275,6 @@ ath_txq_update(struct ath_softc *sc, int ac) ath_hal_resettxqueue(ah, txq->axq_qnum); /* push to h/w */ return 1; } -#undef ATH_TXOP_TO_US #undef ATH_EXPONENT_TO_VALUE } @@ -6302,7 +6296,6 @@ ath_rate_setup(struct ath_softc *sc, u_int mode) static void ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) { -#define N(a) (sizeof(a)/sizeof(a[0])) /* NB: on/off times from the Atheros NDIS driver, w/ permission */ static const struct { u_int rate; /* tx/rx 802.11 rate */ @@ -6339,7 +6332,7 @@ ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i; } memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); - for (i = 0; i < N(sc->sc_hwmap); i++) { + for (i = 0; i < nitems(sc->sc_hwmap); i++) { if (i >= rt->rateCount) { sc->sc_hwmap[i].ledon = (500 * hz) / 1000; sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; @@ -6354,7 +6347,7 @@ ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) rt->info[i].phy == IEEE80211_T_OFDM) sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags; - for (j = 0; j < N(blinkrates)-1; j++) + for (j = 0; j < nitems(blinkrates)-1; j++) if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) break; /* NB: this uses the last entry if the rate isn't found */ @@ -6373,7 +6366,6 @@ ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) else sc->sc_protrix = ath_tx_findrix(sc, 2*1); /* NB: caller is responsible for resetting rate control state */ -#undef N } static void diff --git a/sys/dev/ath/if_ath_beacon.c b/sys/dev/ath/if_ath_beacon.c index 41267b3..1ef3d58 100644 --- a/sys/dev/ath/if_ath_beacon.c +++ b/sys/dev/ath/if_ath_beacon.c @@ -199,7 +199,7 @@ ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni) * we assume the mbuf routines will return us something * with this alignment (perhaps should assert). */ - m = ieee80211_beacon_alloc(ni, &avp->av_boff); + m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off); if (m == NULL) { device_printf(sc->sc_dev, "%s: cannot get mbuf\n", __func__); sc->sc_stats.ast_be_nombuf++; @@ -374,7 +374,7 @@ ath_beacon_setup(struct ath_softc *sc, struct ath_buf *bf) void ath_beacon_update(struct ieee80211vap *vap, int item) { - struct ieee80211_beacon_offsets *bo = &ATH_VAP(vap)->av_boff; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; setbit(bo->bo_flags, item); } @@ -713,7 +713,7 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) /* XXX lock mcastq? */ nmcastq = avp->av_mcastq.axq_depth; - if (ieee80211_beacon_update(bf->bf_node, &avp->av_boff, m, nmcastq)) { + if (ieee80211_beacon_update(bf->bf_node, &vap->iv_bcn_off, m, nmcastq)) { /* XXX too conservative? */ bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, @@ -726,7 +726,7 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) return NULL; } } - if ((avp->av_boff.bo_tim[4] & 1) && cabq->axq_depth) { + if ((vap->iv_bcn_off.bo_tim[4] & 1) && cabq->axq_depth) { DPRINTF(sc, ATH_DEBUG_BEACON, "%s: cabq did not drain, mcastq %u cabq %u\n", __func__, nmcastq, cabq->axq_depth); @@ -764,7 +764,7 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) * Enable the CAB queue before the beacon queue to * insure cab frames are triggered by this beacon. */ - if (avp->av_boff.bo_tim[4] & 1) { + if (vap->iv_bcn_off.bo_tim[4] & 1) { /* NB: only at DTIM */ ATH_TXQ_LOCK(&avp->av_mcastq); @@ -829,7 +829,7 @@ ath_beacon_start_adhoc(struct ath_softc *sc, struct ieee80211vap *vap) */ bf = avp->av_bcbuf; m = bf->bf_m; - if (ieee80211_beacon_update(bf->bf_node, &avp->av_boff, m, 0)) { + if (ieee80211_beacon_update(bf->bf_node, &vap->iv_bcn_off, m, 0)) { /* XXX too conservative? */ bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, diff --git a/sys/dev/ath/if_ath_keycache.c b/sys/dev/ath/if_ath_keycache.c index b8a77e8..f81785f 100644 --- a/sys/dev/ath/if_ath_keycache.c +++ b/sys/dev/ath/if_ath_keycache.c @@ -184,7 +184,6 @@ ath_keyset(struct ath_softc *sc, struct ieee80211vap *vap, const struct ieee80211_key *k, struct ieee80211_node *bss) { -#define N(a) (sizeof(a)/sizeof(a[0])) static const u_int8_t ciphermap[] = { HAL_CIPHER_WEP, /* IEEE80211_CIPHER_WEP */ HAL_CIPHER_TKIP, /* IEEE80211_CIPHER_TKIP */ @@ -208,7 +207,7 @@ ath_keyset(struct ath_softc *sc, struct ieee80211vap *vap, * so that rx frames have an entry to match. */ if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) { - KASSERT(cip->ic_cipher < N(ciphermap), + KASSERT(cip->ic_cipher < nitems(ciphermap), ("invalid cipher type %u", cip->ic_cipher)); hk.kv_type = ciphermap[cip->ic_cipher]; hk.kv_len = k->wk_keylen; @@ -266,7 +265,6 @@ ath_keyset(struct ath_softc *sc, struct ieee80211vap *vap, ATH_UNLOCK(sc); return (ret); -#undef N } /* @@ -277,12 +275,11 @@ static u_int16_t key_alloc_2pair(struct ath_softc *sc, ieee80211_keyix *txkeyix, ieee80211_keyix *rxkeyix) { -#define N(a) (sizeof(a)/sizeof(a[0])) u_int i, keyix; KASSERT(sc->sc_splitmic, ("key cache !split")); /* XXX could optimize */ - for (i = 0; i < N(sc->sc_keymap)/4; i++) { + for (i = 0; i < nitems(sc->sc_keymap)/4; i++) { u_int8_t b = sc->sc_keymap[i]; if (b != 0xff) { /* @@ -321,7 +318,6 @@ key_alloc_2pair(struct ath_softc *sc, } DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__); return 0; -#undef N } /* @@ -332,12 +328,11 @@ static u_int16_t key_alloc_pair(struct ath_softc *sc, ieee80211_keyix *txkeyix, ieee80211_keyix *rxkeyix) { -#define N(a) (sizeof(a)/sizeof(a[0])) u_int i, keyix; KASSERT(!sc->sc_splitmic, ("key cache split")); /* XXX could optimize */ - for (i = 0; i < N(sc->sc_keymap)/4; i++) { + for (i = 0; i < nitems(sc->sc_keymap)/4; i++) { u_int8_t b = sc->sc_keymap[i]; if (b != 0xff) { /* @@ -369,7 +364,6 @@ key_alloc_pair(struct ath_softc *sc, } DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of pair space\n", __func__); return 0; -#undef N } /* @@ -379,7 +373,6 @@ static int key_alloc_single(struct ath_softc *sc, ieee80211_keyix *txkeyix, ieee80211_keyix *rxkeyix) { -#define N(a) (sizeof(a)/sizeof(a[0])) u_int i, keyix; if (sc->sc_hasclrkey == 0) { @@ -391,7 +384,7 @@ key_alloc_single(struct ath_softc *sc, } /* XXX try i,i+32,i+64,i+32+64 to minimize key pair conflicts */ - for (i = 0; i < N(sc->sc_keymap); i++) { + for (i = 0; i < nitems(sc->sc_keymap); i++) { u_int8_t b = sc->sc_keymap[i]; if (b != 0xff) { /* @@ -409,7 +402,6 @@ key_alloc_single(struct ath_softc *sc, } DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s: out of space\n", __func__); return 0; -#undef N } /* diff --git a/sys/dev/ath/if_ath_tdma.c b/sys/dev/ath/if_ath_tdma.c index 99cd61e..e3460c6 100644 --- a/sys/dev/ath/if_ath_tdma.c +++ b/sys/dev/ath/if_ath_tdma.c @@ -548,7 +548,7 @@ ath_tdma_update(struct ieee80211_node *ni, * slot position changes) because ieee80211_add_tdma * skips over the data. */ - memcpy(ATH_VAP(vap)->av_boff.bo_tdma + + memcpy(vap->iv_bcn_off.bo_tdma + __offsetof(struct ieee80211_tdma_param, tdma_tstamp), &ni->ni_tstamp.data, 8); #if 0 diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index 2e71ff6..e25bc7a 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -477,7 +477,6 @@ struct ath_vap { struct ieee80211vap av_vap; /* base class */ int av_bslot; /* beacon slot index */ struct ath_buf *av_bcbuf; /* beacon buffer */ - struct ieee80211_beacon_offsets av_boff;/* dynamic update state */ struct ath_txq av_mcastq; /* buffered mcast s/w queue */ void (*av_recv_mgmt)(struct ieee80211_node *, diff --git a/sys/dev/bwi/bwimac.c b/sys/dev/bwi/bwimac.c index baad7fe..54d2fde 100644 --- a/sys/dev/bwi/bwimac.c +++ b/sys/dev/bwi/bwimac.c @@ -1657,17 +1657,15 @@ bwi_mac_attach(struct bwi_softc *sc, int id, uint8_t rev) /* * Test whether the revision of this MAC is supported */ -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) - for (i = 0; i < N(bwi_sup_macrev); ++i) { + for (i = 0; i < nitems(bwi_sup_macrev); ++i) { if (bwi_sup_macrev[i] == rev) break; } - if (i == N(bwi_sup_macrev)) { + if (i == nitems(bwi_sup_macrev)) { device_printf(sc->sc_dev, "MAC rev %u is " "not supported\n", rev); return ENXIO; } -#undef N BWI_CREATE_MAC(mac, sc, id, rev); sc->sc_nmac++; diff --git a/sys/dev/bwi/bwiphy.c b/sys/dev/bwi/bwiphy.c index 60d6bf5..60afb19 100644 --- a/sys/dev/bwi/bwiphy.c +++ b/sys/dev/bwi/bwiphy.c @@ -185,19 +185,17 @@ bwi_phy_attach(struct bwi_mac *mac) phy->phy_tbl_data_hi = BWI_PHYR_TBL_DATA_HI_11A; break; case BWI_PHYINFO_TYPE_11B: -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) - for (i = 0; i < N(bwi_sup_bphy); ++i) { + for (i = 0; i < nitems(bwi_sup_bphy); ++i) { if (phyrev == bwi_sup_bphy[i].rev) { phy->phy_init = bwi_sup_bphy[i].init; break; } } - if (i == N(bwi_sup_bphy)) { + if (i == nitems(bwi_sup_bphy)) { device_printf(sc->sc_dev, "unsupported 11B PHY, " "rev %u\n", phyrev); return ENXIO; } -#undef N phy->phy_mode = IEEE80211_MODE_11B; break; case BWI_PHYINFO_TYPE_11G: @@ -745,8 +743,6 @@ bwi_phy_init_11b_rev6(struct bwi_mac *mac) } } -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) - static void bwi_phy_config_11g(struct bwi_mac *mac) { @@ -763,19 +759,19 @@ bwi_phy_config_11g(struct bwi_mac *mac) PHY_WRITE(mac, 0x427, 0x1a); /* Fill frequency table */ - for (i = 0; i < N(bwi_phy_freq_11g_rev1); ++i) { + for (i = 0; i < nitems(bwi_phy_freq_11g_rev1); ++i) { bwi_tbl_write_2(mac, BWI_PHYTBL_FREQ + i, bwi_phy_freq_11g_rev1[i]); } /* Fill noise table */ - for (i = 0; i < N(bwi_phy_noise_11g_rev1); ++i) { + for (i = 0; i < nitems(bwi_phy_noise_11g_rev1); ++i) { bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE + i, bwi_phy_noise_11g_rev1[i]); } /* Fill rotor table */ - for (i = 0; i < N(bwi_phy_rotor_11g_rev1); ++i) { + for (i = 0; i < nitems(bwi_phy_rotor_11g_rev1); ++i) { /* NB: data length is 4 bytes */ bwi_tbl_write_4(mac, BWI_PHYTBL_ROTOR + i, bwi_phy_rotor_11g_rev1[i]); @@ -798,7 +794,7 @@ bwi_phy_config_11g(struct bwi_mac *mac) bwi_tbl_write_2(mac, BWI_PHYTBL_RSSI + i, i); /* Fill noise table */ - for (i = 0; i < N(bwi_phy_noise_11g); ++i) { + for (i = 0; i < nitems(bwi_phy_noise_11g); ++i) { bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE + i, bwi_phy_noise_11g[i]); } @@ -809,13 +805,13 @@ bwi_phy_config_11g(struct bwi_mac *mac) */ if (phy->phy_rev <= 2) { tbl = bwi_phy_noise_scale_11g_rev2; - n = N(bwi_phy_noise_scale_11g_rev2); + n = nitems(bwi_phy_noise_scale_11g_rev2); } else if (phy->phy_rev >= 7 && (PHY_READ(mac, 0x449) & 0x200)) { tbl = bwi_phy_noise_scale_11g_rev7; - n = N(bwi_phy_noise_scale_11g_rev7); + n = nitems(bwi_phy_noise_scale_11g_rev7); } else { tbl = bwi_phy_noise_scale_11g; - n = N(bwi_phy_noise_scale_11g); + n = nitems(bwi_phy_noise_scale_11g); } for (i = 0; i < n; ++i) bwi_tbl_write_2(mac, BWI_PHYTBL_NOISE_SCALE + i, tbl[i]); @@ -825,10 +821,10 @@ bwi_phy_config_11g(struct bwi_mac *mac) */ if (phy->phy_rev == 2) { tbl = bwi_phy_sigma_sq_11g_rev2; - n = N(bwi_phy_sigma_sq_11g_rev2); + n = nitems(bwi_phy_sigma_sq_11g_rev2); } else if (phy->phy_rev > 2 && phy->phy_rev <= 8) { tbl = bwi_phy_sigma_sq_11g_rev7; - n = N(bwi_phy_sigma_sq_11g_rev7); + n = nitems(bwi_phy_sigma_sq_11g_rev7); } else { tbl = NULL; n = 0; @@ -838,7 +834,7 @@ bwi_phy_config_11g(struct bwi_mac *mac) if (phy->phy_rev == 1) { /* Fill delay table */ - for (i = 0; i < N(bwi_phy_delay_11g_rev1); ++i) { + for (i = 0; i < nitems(bwi_phy_delay_11g_rev1); ++i) { bwi_tbl_write_4(mac, BWI_PHYTBL_DELAY + i, bwi_phy_delay_11g_rev1[i]); } @@ -877,8 +873,6 @@ bwi_phy_config_11g(struct bwi_mac *mac) PHY_WRITE(mac, 0x46e, 0x3cf); } -#undef N - /* * Configure Automatic Gain Controller */ diff --git a/sys/dev/bwi/bwirf.c b/sys/dev/bwi/bwirf.c index 615e6df..341e929 100644 --- a/sys/dev/bwi/bwirf.c +++ b/sys/dev/bwi/bwirf.c @@ -1155,7 +1155,6 @@ bwi_rf_map_txpower(struct bwi_mac *mac) } #define IS_VALID_PA_PARAM(p) ((p) != 0 && (p) != -1) -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) /* * Extract PA parameters @@ -1164,10 +1163,10 @@ bwi_rf_map_txpower(struct bwi_mac *mac) sprom_ofs = BWI_SPROM_PA_PARAM_11A; else sprom_ofs = BWI_SPROM_PA_PARAM_11BG; - for (i = 0; i < N(pa_params); ++i) + for (i = 0; i < nitems(pa_params); ++i) pa_params[i] = (int16_t)bwi_read_sprom(sc, sprom_ofs + (i * 2)); - for (i = 0; i < N(pa_params); ++i) { + for (i = 0; i < nitems(pa_params); ++i) { /* * If one of the PA parameters from SPROM is not valid, * fall back to the default values, if there are any. @@ -1200,8 +1199,6 @@ bwi_rf_map_txpower(struct bwi_mac *mac) } } -#undef N - /* * All of the PA parameters from SPROM are valid. */ diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c index 741f5f1..0a220a1 100644 --- a/sys/dev/bwi/if_bwi.c +++ b/sys/dev/bwi/if_bwi.c @@ -762,7 +762,6 @@ bwi_regwin_info(struct bwi_softc *sc, uint16_t *type, uint8_t *rev) static int bwi_bbp_attach(struct bwi_softc *sc) { -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) uint16_t bbp_id, rw_type; uint8_t rw_rev; uint32_t info; @@ -792,7 +791,7 @@ bwi_bbp_attach(struct bwi_softc *sc) sc->sc_cap = CSR_READ_4(sc, BWI_CAPABILITY); } else { - for (i = 0; i < N(bwi_bbpid_map); ++i) { + for (i = 0; i < nitems(bwi_bbpid_map); ++i) { if (sc->sc_pci_did >= bwi_bbpid_map[i].did_min && sc->sc_pci_did <= bwi_bbpid_map[i].did_max) { bbp_id = bwi_bbpid_map[i].bbp_id; @@ -816,7 +815,7 @@ bwi_bbp_attach(struct bwi_softc *sc) if (rw_type == BWI_REGWIN_T_COM && rw_rev >= 4) { nregwin = __SHIFTOUT(info, BWI_INFO_NREGWIN_MASK); } else { - for (i = 0; i < N(bwi_regwin_count); ++i) { + for (i = 0; i < nitems(bwi_regwin_count); ++i) { if (bwi_regwin_count[i].bbp_id == bbp_id) { nregwin = bwi_regwin_count[i].nregwin; break; @@ -898,7 +897,6 @@ bwi_bbp_attach(struct bwi_softc *sc) return error; return 0; -#undef N } int @@ -3765,9 +3763,7 @@ bwi_led_attach(struct bwi_softc *sc) uint16_t gpio, val[BWI_LED_MAX]; int i; -#define N(arr) (int)(sizeof(arr) / sizeof(arr[0])) - - for (i = 0; i < N(bwi_vendor_led_act); ++i) { + for (i = 0; i < nitems(bwi_vendor_led_act); ++i) { if (sc->sc_pci_subvid == bwi_vendor_led_act[i].vid) { led_act = bwi_vendor_led_act[i].led_act; break; @@ -3776,8 +3772,6 @@ bwi_led_attach(struct bwi_softc *sc) if (led_act == NULL) led_act = bwi_default_led_act; -#undef N - gpio = bwi_read_sprom(sc, BWI_SPROM_GPIO01); val[0] = __SHIFTOUT(gpio, BWI_SPROM_GPIO_0); val[1] = __SHIFTOUT(gpio, BWI_SPROM_GPIO_1); diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c index 1ffd24c..c4f47e4 100644 --- a/sys/dev/ipw/if_ipw.c +++ b/sys/dev/ipw/if_ipw.c @@ -1417,7 +1417,6 @@ ipw_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) static const char * ipw_cmdname(int cmd) { -#define N(a) (sizeof(a) / sizeof(a[0])) static const struct { int cmd; const char *name; @@ -1454,12 +1453,11 @@ ipw_cmdname(int cmd) static char buf[12]; int i; - for (i = 0; i < N(cmds); i++) + for (i = 0; i < nitems(cmds); i++) if (cmds[i].cmd == cmd) return cmds[i].name; snprintf(buf, sizeof(buf), "%u", cmd); return buf; -#undef N } /* diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c index 73631ea..c45a37f 100644 --- a/sys/dev/iwi/if_iwi.c +++ b/sys/dev/iwi/if_iwi.c @@ -3415,7 +3415,6 @@ iwi_led_blink(struct iwi_softc *sc, int on, int off) static void iwi_led_event(struct iwi_softc *sc, int event) { -#define N(a) (sizeof(a)/sizeof(a[0])) /* NB: on/off times from the Atheros NDIS driver, w/ permission */ static const struct { u_int rate; /* tx/rx iwi rate */ @@ -3445,13 +3444,13 @@ iwi_led_event(struct iwi_softc *sc, int event) return; switch (event) { case IWI_LED_POLL: - j = N(blinkrates)-1; + j = nitems(blinkrates)-1; break; case IWI_LED_TX: /* read current transmission rate from adapter */ txrate = CSR_READ_4(sc, IWI_CSR_CURRENT_TX_RATE); if (blinkrates[sc->sc_txrix].rate != txrate) { - for (j = 0; j < N(blinkrates)-1; j++) + for (j = 0; j < nitems(blinkrates)-1; j++) if (blinkrates[j].rate == txrate) break; sc->sc_txrix = j; @@ -3460,7 +3459,7 @@ iwi_led_event(struct iwi_softc *sc, int event) break; case IWI_LED_RX: if (blinkrates[sc->sc_rxrix].rate != sc->sc_rxrate) { - for (j = 0; j < N(blinkrates)-1; j++) + for (j = 0; j < nitems(blinkrates)-1; j++) if (blinkrates[j].rate == sc->sc_rxrate) break; sc->sc_rxrix = j; @@ -3471,7 +3470,6 @@ iwi_led_event(struct iwi_softc *sc, int event) /* XXX beware of overflow */ iwi_led_blink(sc, (blinkrates[j].timeOn * hz) / 1000, (blinkrates[j].timeOff * hz) / 1000); -#undef N } static int diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index ecaab2d..5e6876d 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -2716,7 +2716,6 @@ static uint32_t iwn_rate_to_plcp(struct iwn_softc *sc, struct ieee80211_node *ni, uint8_t rate) { -#define RV(v) ((v) & IEEE80211_RATE_VAL) struct ieee80211com *ic = ni->ni_ic; uint32_t plcp = 0; int ridx; @@ -2731,7 +2730,7 @@ iwn_rate_to_plcp(struct iwn_softc *sc, struct ieee80211_node *ni, * MCS 0 -> MCS 31, then set the "I'm an MCS rate!" * flag. */ - plcp = RV(rate) | IWN_RFLAG_MCS; + plcp = IEEE80211_RV(rate) | IWN_RFLAG_MCS; /* * XXX the following should only occur if both @@ -2792,7 +2791,6 @@ iwn_rate_to_plcp(struct iwn_softc *sc, struct ieee80211_node *ni, plcp); return (htole32(plcp)); -#undef RV } static void @@ -5179,7 +5177,6 @@ iwn5000_add_node(struct iwn_softc *sc, struct iwn_node_info *node, int async) static int iwn_set_link_quality(struct iwn_softc *sc, struct ieee80211_node *ni) { -#define RV(v) ((v) & IEEE80211_RATE_VAL) struct iwn_node *wn = (void *)ni; struct ieee80211_rateset *rs; struct iwn_cmd_link_quality linkq; @@ -5238,7 +5235,7 @@ iwn_set_link_quality(struct iwn_softc *sc, struct ieee80211_node *ni) if (is_11n) rate = IEEE80211_RATE_MCS | rs->rs_rates[txrate]; else - rate = RV(rs->rs_rates[txrate]); + rate = IEEE80211_RV(rs->rs_rates[txrate]); /* Do rate -> PLCP config mapping */ plcp = iwn_rate_to_plcp(sc, ni, rate); @@ -5263,7 +5260,7 @@ iwn_set_link_quality(struct iwn_softc *sc, struct ieee80211_node *ni) * entry, we're already pointing at it. */ if ((le32toh(plcp) & IWN_RFLAG_MCS) && - RV(le32toh(plcp)) > 7) + IEEE80211_RV(le32toh(plcp)) > 7) linkq.mimo = i + 1; /* Next retry at immediate lower bit-rate. */ @@ -5283,7 +5280,6 @@ iwn_set_link_quality(struct iwn_softc *sc, struct ieee80211_node *ni) DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); return iwn_cmd(sc, IWN_CMD_LINK_QUALITY, &linkq, sizeof linkq, 1); -#undef RV } /* diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index 2790fdc..251ddc6 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -901,22 +901,18 @@ malo_printtxbuf(const struct malo_txbuf *bf, u_int qnum, u_int ix) static __inline void malo_updatetxrate(struct ieee80211_node *ni, int rix) { -#define N(x) (sizeof(x)/sizeof(x[0])) static const int ieeerates[] = { 2, 4, 11, 22, 44, 12, 18, 24, 36, 48, 96, 108 }; - if (rix < N(ieeerates)) + if (rix < nitems(ieeerates)) ni->ni_txrate = ieeerates[rix]; -#undef N } static int malo_fix2rate(int fix_rate) { -#define N(x) (sizeof(x)/sizeof(x[0])) static const int rates[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 96, 108 }; - return (fix_rate < N(rates) ? rates[fix_rate] : 0); -#undef N + return (fix_rate < nitems(rates) ? rates[fix_rate] : 0); } /* idiomatic shorthands: MS = mask+shift, SM = shift+mask */ @@ -1034,8 +1030,6 @@ static int malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, struct malo_txbuf *bf, struct mbuf *m0) { -#define IEEE80211_DIR_DSTODS(wh) \ - ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) #define IS_DATA_FRAME(wh) \ ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK)) == IEEE80211_FC0_TYPE_DATA) int error, ismcast, iswep; @@ -1054,7 +1048,7 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, copyhdrlen = hdrlen = ieee80211_anyhdrsize(wh); pktlen = m0->m_pkthdr.len; if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_DIR_DSTODS(wh)) { + if (IEEE80211_IS_DSTODS(wh)) { qos = *(uint16_t *) (((struct ieee80211_qosframe_addr4 *) wh)->i_qos); copyhdrlen -= sizeof(qos); @@ -1210,7 +1204,6 @@ malo_tx_start(struct malo_softc *sc, struct ieee80211_node *ni, sc->malo_timer = 5; MALO_TXQ_UNLOCK(txq); return 0; -#undef IEEE80211_DIR_DSTODS } static int @@ -1960,9 +1953,6 @@ malo_set_channel(struct ieee80211com *ic) static void malo_rx_proc(void *arg, int npending) { -#define IEEE80211_DIR_DSTODS(wh) \ - ((((const struct ieee80211_frame *)wh)->i_fc[1] & \ - IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) struct malo_softc *sc = arg; struct ieee80211com *ic = &sc->malo_ic; struct malo_rxbuf *bf; @@ -2080,7 +2070,7 @@ malo_rx_proc(void *arg, int npending) /* XXX special case so we can memcpy after m_devget? */ ovbcopy(data + sizeof(uint16_t), wh, hdrlen); if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_DIR_DSTODS(wh)) { + if (IEEE80211_IS_DSTODS(wh)) { wh4 = mtod(m, struct ieee80211_qosframe_addr4*); *(uint16_t *)wh4->i_qos = ds->qosctrl; @@ -2119,7 +2109,6 @@ rx_next: if (mbufq_first(&sc->malo_snd) != NULL) malo_start(sc); -#undef IEEE80211_DIR_DSTODS } /* diff --git a/sys/dev/malo/if_malo_pci.c b/sys/dev/malo/if_malo_pci.c index 26324c0..01b519e 100644 --- a/sys/dev/malo/if_malo_pci.c +++ b/sys/dev/malo/if_malo_pci.c @@ -131,7 +131,6 @@ static int malo_pci_detach(device_t); static int malo_pci_probe(device_t dev) { -#define N(a) (sizeof(a) / sizeof((a)[0])) struct malo_product *mp; uint16_t vendor, devid; int i; @@ -140,7 +139,7 @@ malo_pci_probe(device_t dev) devid = pci_get_device(dev); mp = malo_products; - for (i = 0; i < N(malo_products); i++, mp++) { + for (i = 0; i < nitems(malo_products); i++, mp++) { if (vendor == mp->mp_vendorid && devid == mp->mp_deviceid) { device_set_desc(dev, mp->mp_name); return (BUS_PROBE_DEFAULT); @@ -148,7 +147,6 @@ malo_pci_probe(device_t dev) } return (ENXIO); -#undef N } static int diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index be80e46..463b5c9 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include <net/bpf.h> #include <net80211/ieee80211_var.h> +#include <net80211/ieee80211_input.h> #include <net80211/ieee80211_regdomain.h> #ifdef INET @@ -1707,18 +1708,6 @@ mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k, #undef GRPXMIT } -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((uint16_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((uint32_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8) | \ - (((const uint8_t *)(p))[2] << 16) | \ - (((const uint8_t *)(p))[3] << 24))) - /* * Set the multicast filter contents into the hardware. * XXX f/w has no support; just defer to the os. @@ -1845,10 +1834,10 @@ mwl_beacon_setup(struct ieee80211vap *vap) { struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; struct ieee80211_node *ni = vap->iv_bss; - struct ieee80211_beacon_offsets bo; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; struct mbuf *m; - m = ieee80211_beacon_alloc(ni, &bo); + m = ieee80211_beacon_alloc(ni, bo); if (m == NULL) return ENOBUFS; mwl_hal_setbeacon(hvap, mtod(m, const void *), m->m_len); @@ -2619,8 +2608,6 @@ cvtrssi(uint8_t ssi) static void mwl_rx_proc(void *arg, int npending) { -#define IEEE80211_DIR_DSTODS(wh) \ - ((((const struct ieee80211_frame *)wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) struct mwl_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; struct mwl_rxbuf *bf; @@ -2775,7 +2762,7 @@ mwl_rx_proc(void *arg, int npending) /* XXX special case so we can memcpy after m_devget? */ ovbcopy(data + sizeof(uint16_t), wh, hdrlen); if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_DIR_DSTODS(wh)) { + if (IEEE80211_IS_DSTODS(wh)) { wh4 = mtod(m, struct ieee80211_qosframe_addr4*); *(uint16_t *)wh4->i_qos = ds->QosCtrl; @@ -2845,7 +2832,6 @@ rx_stop: mwl_hal_txstart(sc->sc_mh, 0); mwl_start(sc); } -#undef IEEE80211_DIR_DSTODS } static void @@ -2881,12 +2867,11 @@ mwl_txq_init(struct mwl_softc *sc, struct mwl_txq *txq, int qnum) static int mwl_tx_setup(struct mwl_softc *sc, int ac, int mvtype) { -#define N(a) (sizeof(a)/sizeof(a[0])) struct mwl_txq *txq; - if (ac >= N(sc->sc_ac2q)) { + if (ac >= nitems(sc->sc_ac2q)) { device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", - ac, N(sc->sc_ac2q)); + ac, nitems(sc->sc_ac2q)); return 0; } if (mvtype >= MWL_NUM_TX_QUEUES) { @@ -2898,7 +2883,6 @@ mwl_tx_setup(struct mwl_softc *sc, int ac, int mvtype) mwl_txq_init(sc, txq, mvtype); sc->sc_ac2q[ac] = txq; return 1; -#undef N } /* @@ -3091,8 +3075,6 @@ static int mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf *bf, struct mbuf *m0) { -#define IEEE80211_DIR_DSTODS(wh) \ - ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = ni->ni_vap; int error, iswep, ismcast; @@ -3114,7 +3096,7 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf * copyhdrlen = hdrlen; pktlen = m0->m_pkthdr.len; if (IEEE80211_QOS_HAS_SEQ(wh)) { - if (IEEE80211_DIR_DSTODS(wh)) { + if (IEEE80211_IS_DSTODS(wh)) { qos = *(uint16_t *) (((struct ieee80211_qosframe_addr4 *) wh)->i_qos); copyhdrlen -= sizeof(qos); @@ -3331,17 +3313,14 @@ mwl_tx_start(struct mwl_softc *sc, struct ieee80211_node *ni, struct mwl_txbuf * MWL_TXQ_UNLOCK(txq); return 0; -#undef IEEE80211_DIR_DSTODS } static __inline int mwl_cvtlegacyrix(int rix) { -#define N(x) (sizeof(x)/sizeof(x[0])) static const int ieeerates[] = { 2, 4, 11, 22, 44, 12, 18, 24, 36, 48, 72, 96, 108 }; - return (rix < N(ieeerates) ? ieeerates[rix] : 0); -#undef N + return (rix < nitems(ieeerates) ? ieeerates[rix] : 0); } /* diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c index ea9c416..ef5a01c 100644 --- a/sys/dev/ral/rt2560.c +++ b/sys/dev/ral/rt2560.c @@ -768,7 +768,7 @@ rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) if (vap->iv_opmode == IEEE80211_M_HOSTAP || vap->iv_opmode == IEEE80211_M_IBSS || vap->iv_opmode == IEEE80211_M_MBSS) { - m = ieee80211_beacon_alloc(ni, &rvp->ral_bo); + m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off); if (m == NULL) { device_printf(sc->sc_dev, "could not allocate beacon\n"); @@ -1273,8 +1273,7 @@ rt2560_rx_intr(struct rt2560_softc *sc) static void rt2560_beacon_update(struct ieee80211vap *vap, int item) { - struct rt2560_vap *rvp = RT2560_VAP(vap); - struct ieee80211_beacon_offsets *bo = &rvp->ral_bo; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; setbit(bo->bo_flags, item); } @@ -1288,7 +1287,6 @@ rt2560_beacon_expire(struct rt2560_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); - struct rt2560_vap *rvp = RT2560_VAP(vap); struct rt2560_tx_data *data; if (ic->ic_opmode != IEEE80211_M_IBSS && @@ -1307,7 +1305,7 @@ rt2560_beacon_expire(struct rt2560_softc *sc) bus_dmamap_unload(sc->bcnq.data_dmat, data->map); /* XXX 1 =>'s mcast frames which means all PS sta's will wakeup! */ - ieee80211_beacon_update(data->ni, &rvp->ral_bo, data->m, 1); + ieee80211_beacon_update(data->ni, &vap->iv_bcn_off, data->m, 1); rt2560_tx_bcn(sc, data->m, data->ni); @@ -2301,7 +2299,6 @@ static void rt2560_set_basicrates(struct rt2560_softc *sc, const struct ieee80211_rateset *rs) { -#define RV(r) ((r) & IEEE80211_RATE_VAL) struct ieee80211com *ic = &sc->sc_ic; uint32_t mask = 0; uint8_t rate; @@ -2313,13 +2310,13 @@ rt2560_set_basicrates(struct rt2560_softc *sc, if (!(rate & IEEE80211_RATE_BASIC)) continue; - mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt, RV(rate)); + mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt, + IEEE80211_RV(rate)); } RAL_WRITE(sc, RT2560_ARSP_PLCP_1, mask); DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask); -#undef RV } static void @@ -2478,7 +2475,6 @@ rt2560_scan_end(struct ieee80211com *ic) static int rt2560_bbp_init(struct rt2560_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) int i, ntries; /* wait for BBP to be ready */ @@ -2493,7 +2489,7 @@ rt2560_bbp_init(struct rt2560_softc *sc) } /* initialize BBP registers to default values */ - for (i = 0; i < N(rt2560_def_bbp); i++) { + for (i = 0; i < nitems(rt2560_def_bbp); i++) { rt2560_bbp_write(sc, rt2560_def_bbp[i].reg, rt2560_def_bbp[i].val); } @@ -2507,7 +2503,6 @@ rt2560_bbp_init(struct rt2560_softc *sc) rt2560_bbp_write(sc, 17, 0x48); /* XXX restore bbp17 */ return 0; -#undef N } static void @@ -2560,7 +2555,6 @@ rt2560_set_rxantenna(struct rt2560_softc *sc, int antenna) static void rt2560_init_locked(struct rt2560_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); uint32_t tmp; @@ -2590,7 +2584,7 @@ rt2560_init_locked(struct rt2560_softc *sc) RAL_WRITE(sc, RT2560_RXCSR2, sc->rxq.physaddr); /* initialize MAC registers to default values */ - for (i = 0; i < N(rt2560_def_mac); i++) + for (i = 0; i < nitems(rt2560_def_mac); i++) RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val); rt2560_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); @@ -2641,7 +2635,6 @@ rt2560_init_locked(struct rt2560_softc *sc) sc->sc_flags |= RT2560_F_RUNNING; callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc); -#undef N } static void diff --git a/sys/dev/ral/rt2560var.h b/sys/dev/ral/rt2560var.h index 3a5fef9..12601d8 100644 --- a/sys/dev/ral/rt2560var.h +++ b/sys/dev/ral/rt2560var.h @@ -97,7 +97,6 @@ struct rt2560_rx_ring { struct rt2560_vap { struct ieee80211vap ral_vap; - struct ieee80211_beacon_offsets ral_bo; int (*ral_newstate)(struct ieee80211vap *, enum ieee80211_state, int); diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c index c77d4f8..5c73ba0 100644 --- a/sys/dev/ral/rt2661.c +++ b/sys/dev/ral/rt2661.c @@ -1859,7 +1859,6 @@ static void rt2661_set_basicrates(struct rt2661_softc *sc, const struct ieee80211_rateset *rs) { -#define RV(r) ((r) & IEEE80211_RATE_VAL) struct ieee80211com *ic = &sc->sc_ic; uint32_t mask = 0; uint8_t rate; @@ -1871,13 +1870,13 @@ rt2661_set_basicrates(struct rt2661_softc *sc, if (!(rate & IEEE80211_RATE_BASIC)) continue; - mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt, RV(rate)); + mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt, + IEEE80211_RV(rate)); } RAL_WRITE(sc, RT2661_TXRX_CSR5, mask); DPRINTF(sc, "Setting basic rate mask to 0x%x\n", mask); -#undef RV } /* @@ -2208,7 +2207,6 @@ rt2661_read_eeprom(struct rt2661_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN]) static int rt2661_bbp_init(struct rt2661_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) int i, ntries; uint8_t val; @@ -2225,7 +2223,7 @@ rt2661_bbp_init(struct rt2661_softc *sc) } /* initialize BBP registers to default values */ - for (i = 0; i < N(rt2661_def_bbp); i++) { + for (i = 0; i < nitems(rt2661_def_bbp); i++) { rt2661_bbp_write(sc, rt2661_def_bbp[i].reg, rt2661_def_bbp[i].val); } @@ -2238,13 +2236,11 @@ rt2661_bbp_init(struct rt2661_softc *sc) } return 0; -#undef N } static void rt2661_init_locked(struct rt2661_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); uint32_t tmp, sta[3]; @@ -2305,7 +2301,7 @@ rt2661_init_locked(struct rt2661_softc *sc) RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 2); /* initialize MAC registers to default values */ - for (i = 0; i < N(rt2661_def_mac); i++) + for (i = 0; i < nitems(rt2661_def_mac); i++) RAL_WRITE(sc, rt2661_def_mac[i].reg, rt2661_def_mac[i].val); rt2661_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); @@ -2354,7 +2350,7 @@ rt2661_init_locked(struct rt2661_softc *sc) RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp); /* clear STA registers */ - RAL_READ_REGION_4(sc, RT2661_STA_CSR0, sta, N(sta)); + RAL_READ_REGION_4(sc, RT2661_STA_CSR0, sta, nitems(sta)); /* initialize ASIC */ RAL_WRITE(sc, RT2661_MAC_CSR1, 4); @@ -2372,7 +2368,6 @@ rt2661_init_locked(struct rt2661_softc *sc) sc->sc_flags |= RAL_RUNNING; callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc); -#undef N } static void @@ -2631,12 +2626,12 @@ static int rt2661_prepare_beacon(struct rt2661_softc *sc, struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; - struct ieee80211_beacon_offsets bo; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; struct rt2661_tx_desc desc; struct mbuf *m0; int rate; - m0 = ieee80211_beacon_alloc(vap->iv_bss, &bo); + m0 = ieee80211_beacon_alloc(vap->iv_bss, bo); if (m0 == NULL) { device_printf(sc->sc_dev, "could not allocate beacon frame\n"); return ENOBUFS; diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c index 48c3ed8..a6b1e26 100644 --- a/sys/dev/ral/rt2860.c +++ b/sys/dev/ral/rt2860.c @@ -2260,7 +2260,6 @@ void rt2860_set_basicrates(struct rt2860_softc *sc, const struct ieee80211_rateset *rs) { -#define RV(r) ((r) & IEEE80211_RATE_VAL) struct ieee80211com *ic = &sc->sc_ic; uint32_t mask = 0; uint8_t rate; @@ -2272,11 +2271,11 @@ rt2860_set_basicrates(struct rt2860_softc *sc, if (!(rate & IEEE80211_RATE_BASIC)) continue; - mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt, RV(rate)); + mask |= 1 << ieee80211_legacy_rate_lookup(ic->ic_rt, + IEEE80211_RV(rate)); } RAL_WRITE(sc, RT2860_LEGACY_BASIC_RATE, mask); -#undef RV } static void @@ -4269,12 +4268,12 @@ static int rt2860_setup_beacon(struct rt2860_softc *sc, struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; - struct ieee80211_beacon_offsets bo; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; struct rt2860_txwi txwi; struct mbuf *m; int ridx; - if ((m = ieee80211_beacon_alloc(vap->iv_bss, &bo)) == NULL) + if ((m = ieee80211_beacon_alloc(vap->iv_bss, bo)) == NULL) return ENOBUFS; memset(&txwi, 0, sizeof txwi); diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c index b29598d..2337067 100644 --- a/sys/dev/usb/wlan/if_rsu.c +++ b/sys/dev/usb/wlan/if_rsu.c @@ -22,9 +22,11 @@ __FBSDID("$FreeBSD$"); * Driver for Realtek RTL8188SU/RTL8191SU/RTL8192SU. * * TODO: - * o 11n support + * o 11n HT40 support * o h/w crypto * o hostap / ibss / mesh + * o sensible RSSI levels + * o power-save operation */ #include <sys/param.h> @@ -84,7 +86,7 @@ SYSCTL_INT(_hw_usb_rsu, OID_AUTO, debug, CTLFLAG_RWTUN, &rsu_debug, 0, #define RSU_DPRINTF(_sc, _flg, ...) #endif -static int rsu_enable_11n = 0; +static int rsu_enable_11n = 1; TUNABLE_INT("hw.usb.rsu.enable_11n", &rsu_enable_11n); #define RSU_DEBUG_ANY 0xffffffff @@ -98,6 +100,7 @@ TUNABLE_INT("hw.usb.rsu.enable_11n", &rsu_enable_11n); #define RSU_DEBUG_TXDONE 0x00000080 #define RSU_DEBUG_FW 0x00000100 #define RSU_DEBUG_FWDBG 0x00000200 +#define RSU_DEBUG_AMPDU 0x00000400 static const STRUCT_USB_HOST_ID rsu_devs[] = { #define RSU_HT_NOT_SUPPORTED 0 @@ -190,6 +193,7 @@ static uint8_t rsu_efuse_read_1(struct rsu_softc *, uint16_t); static int rsu_read_rom(struct rsu_softc *); static int rsu_fw_cmd(struct rsu_softc *, uint8_t, void *, int); static void rsu_calib_task(void *, int); +static void rsu_tx_task(void *, int); static int rsu_newstate(struct ieee80211vap *, enum ieee80211_state, int); #ifdef notyet static void rsu_set_key(struct rsu_softc *, const struct ieee80211_key *); @@ -217,6 +221,7 @@ static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *, struct mbuf *, struct rsu_data *); static int rsu_transmit(struct ieee80211com *, struct mbuf *); static void rsu_start(struct rsu_softc *); +static void _rsu_start(struct rsu_softc *); static void rsu_parent(struct ieee80211com *); static void rsu_stop(struct rsu_softc *); static void rsu_ms_delay(struct rsu_softc *, int); @@ -332,11 +337,51 @@ rsu_update_chw(struct ieee80211com *ic) } +/* + * notification from net80211 that it'd like to do A-MPDU on the given TID. + * + * Note: this actually hangs traffic at the present moment, so don't use it. + * The firmware debug does indiciate it's sending and establishing a TX AMPDU + * session, but then no traffic flows. + */ static int rsu_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) { +#if 0 + struct rsu_softc *sc = ni->ni_ic->ic_softc; + struct r92s_add_ba_req req; - /* Firmware handles this; not our problem */ + /* Don't enable if it's requested or running */ + if (IEEE80211_AMPDU_REQUESTED(tap)) + return (0); + if (IEEE80211_AMPDU_RUNNING(tap)) + return (0); + + /* We've decided to send addba; so send it */ + req.tid = htole32(tap->txa_tid); + + /* Attempt net80211 state */ + if (ieee80211_ampdu_tx_request_ext(ni, tap->txa_tid) != 1) + return (0); + + /* Send the firmware command */ + RSU_DPRINTF(sc, RSU_DEBUG_AMPDU, "%s: establishing AMPDU TX for TID %d\n", + __func__, + tap->txa_tid); + + RSU_LOCK(sc); + if (rsu_fw_cmd(sc, R92S_CMD_ADDBA_REQ, &req, sizeof(req)) != 1) { + RSU_UNLOCK(sc); + /* Mark failure */ + (void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 0); + return (0); + } + RSU_UNLOCK(sc); + + /* Mark success; we don't get any further notifications */ + (void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 1); +#endif + /* Return 0, we're driving this ourselves */ return (0); } @@ -379,6 +424,7 @@ rsu_attach(device_t self) MTX_DEF); TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_task, 0, rsu_calib_task, sc); + TASK_INIT(&sc->tx_task, 0, rsu_tx_task, sc); mbufq_init(&sc->sc_snd, ifqmaxlen); /* Allocate Tx/Rx buffers. */ @@ -445,7 +491,13 @@ rsu_attach(device_t self) IEEE80211_HTCAP_MAXAMSDU_3839 | IEEE80211_HTCAP_SMPS_OFF; + /* + * XXX HT40 isn't working in this driver yet - there's + * something missing. Disable it for now. + */ +#if 0 ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40; +#endif /* set number of spatial streams */ ic->ic_txstream = 1; @@ -502,15 +554,17 @@ rsu_detach(device_t self) rsu_stop(sc); RSU_UNLOCK(sc); usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER); + + /* Frames are freed; detach from net80211 */ ieee80211_ifdetach(ic); taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task); + taskqueue_drain(taskqueue_thread, &sc->tx_task); /* Free Tx/Rx buffers. */ rsu_free_tx_list(sc); rsu_free_rx_list(sc); - mbufq_drain(&sc->sc_snd); mtx_destroy(&sc->sc_mtx); return (0); @@ -593,6 +647,7 @@ rsu_scan_start(struct ieee80211com *ic) /* Scanning is done by the firmware. */ RSU_LOCK(sc); + /* XXX TODO: force awake if in in network-sleep? */ error = rsu_site_survey(sc, TAILQ_FIRST(&ic->ic_vaps)); RSU_UNLOCK(sc); if (error != 0) @@ -753,6 +808,9 @@ rsu_getbuf(struct rsu_softc *sc) RSU_ASSERT_LOCKED(sc); bf = _rsu_getbuf(sc); + if (bf == NULL) { + RSU_DPRINTF(sc, RSU_DEBUG_TX, "%s: no buffers\n", __func__); + } return (bf); } @@ -949,7 +1007,11 @@ rsu_fw_cmd(struct rsu_softc *sc, uint8_t code, void *buf, int len) if (data == NULL) return (ENOMEM); + /* Blank the entire payload, just to be safe */ + memset(data->buf, '\0', RSU_TXBUFSZ); + /* Round-up command length to a multiple of 8 bytes. */ + /* XXX TODO: is this required? */ cmdsz = (len + 7) & ~7; xferlen = sizeof(*txd) + sizeof(*cmd) + cmdsz; @@ -1016,6 +1078,85 @@ rsu_calib_task(void *arg, int pending __unused) RSU_UNLOCK(sc); } +static void +rsu_tx_task(void *arg, int pending __unused) +{ + struct rsu_softc *sc = arg; + + RSU_LOCK(sc); + _rsu_start(sc); + RSU_UNLOCK(sc); +} + +#define RSU_PWR_UNKNOWN 0x0 +#define RSU_PWR_ACTIVE 0x1 +#define RSU_PWR_OFF 0x2 +#define RSU_PWR_SLEEP 0x3 + +/* + * Set the current power state. + * + * The rtlwifi code doesn't do this so aggressively; it + * waits for an idle period after association with + * no traffic before doing this. + * + * For now - it's on in all states except RUN, and + * in RUN it'll transition to allow sleep. + */ + +struct r92s_pwr_cmd { + uint8_t mode; + uint8_t smart_ps; + uint8_t bcn_pass_time; +}; + +static int +rsu_set_fw_power_state(struct rsu_softc *sc, int state) +{ + struct r92s_set_pwr_mode cmd; + //struct r92s_pwr_cmd cmd; + int error; + + RSU_ASSERT_LOCKED(sc); + + /* only change state if required */ + if (sc->sc_curpwrstate == state) + return (0); + + memset(&cmd, 0, sizeof(cmd)); + + switch (state) { + case RSU_PWR_ACTIVE: + /* Force the hardware awake */ + rsu_write_1(sc, R92S_USB_HRPWM, + R92S_USB_HRPWM_PS_ST_ACTIVE | R92S_USB_HRPWM_PS_ALL_ON); + cmd.mode = R92S_PS_MODE_ACTIVE; + break; + case RSU_PWR_SLEEP: + cmd.mode = R92S_PS_MODE_DTIM; /* XXX configurable? */ + cmd.smart_ps = 1; /* XXX 2 if doing p2p */ + cmd.bcn_pass_time = 5; /* in 100mS usb.c, linux/rtlwifi */ + break; + case RSU_PWR_OFF: + cmd.mode = R92S_PS_MODE_RADIOOFF; + break; + default: + device_printf(sc->sc_dev, "%s: unknown ps mode (%d)\n", + __func__, + state); + return (ENXIO); + } + + RSU_DPRINTF(sc, RSU_DEBUG_RESET, + "%s: setting ps mode to %d (mode %d)\n", + __func__, state, cmd.mode); + error = rsu_fw_cmd(sc, R92S_CMD_SET_PWR_MODE, &cmd, sizeof(cmd)); + if (error == 0) + sc->sc_curpwrstate = state; + + return (error); +} + static int rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { @@ -1040,6 +1181,7 @@ rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) sc->sc_calibrating = 0; RSU_UNLOCK(sc); taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task); + taskqueue_drain(taskqueue_thread, &sc->tx_task); /* Disassociate from our current BSS. */ RSU_LOCK(sc); rsu_disconnect(sc); @@ -1047,9 +1189,11 @@ rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) RSU_LOCK(sc); switch (nstate) { case IEEE80211_S_INIT: + (void) rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE); break; case IEEE80211_S_AUTH: ni = ieee80211_ref_node(vap->iv_bss); + (void) rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE); error = rsu_join_bss(sc, ni); ieee80211_free_node(ni); if (error != 0) { @@ -1062,6 +1206,7 @@ rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) rs = &ni->ni_rates; /* Indicate highest supported rate. */ ni->ni_txrate = rs->rs_rates[rs->rs_nrates - 1]; + (void) rsu_set_fw_power_state(sc, RSU_PWR_SLEEP); ieee80211_free_node(ni); startcal = 1; break; @@ -1450,13 +1595,11 @@ rsu_rx_event(struct rsu_softc *sc, uint8_t code, uint8_t *buf, int len) buf[60] = '\0'; RSU_DPRINTF(sc, RSU_DEBUG_FWDBG, "FWDBG: %s\n", (char *)buf); break; - case R92S_EVT_ADDBA_REQ_REPORT: rsu_event_addba_req_report(sc, buf, len); break; default: - RSU_DPRINTF(sc, RSU_DEBUG_ANY, "%s: unhandled code (%d)\n", - __func__, code); + device_printf(sc->sc_dev, "%s: unhandled code (%d)\n", __func__, code); break; } } @@ -1828,19 +1971,34 @@ tr_setup: static void rsu_bulk_tx_callback_be_bk(struct usb_xfer *xfer, usb_error_t error) { + struct rsu_softc *sc = usbd_xfer_softc(xfer); + rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_BE_BK); + + /* This kicks the TX taskqueue */ + rsu_start(sc); } static void rsu_bulk_tx_callback_vi_vo(struct usb_xfer *xfer, usb_error_t error) { + struct rsu_softc *sc = usbd_xfer_softc(xfer); + rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_VI_VO); + + /* This kicks the TX taskqueue */ + rsu_start(sc); } static void rsu_bulk_tx_callback_h2c(struct usb_xfer *xfer, usb_error_t error) { + struct rsu_softc *sc = usbd_xfer_softc(xfer); + rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_H2C); + + /* This kicks the TX taskqueue */ + rsu_start(sc); } static int @@ -1991,17 +2149,38 @@ rsu_transmit(struct ieee80211com *ic, struct mbuf *m) } error = mbufq_enqueue(&sc->sc_snd, m); if (error) { + RSU_DPRINTF(sc, RSU_DEBUG_TX, + "%s: mbufq_enable: failed (%d)\n", + __func__, + error); RSU_UNLOCK(sc); return (error); } - rsu_start(sc); RSU_UNLOCK(sc); + /* This kicks the TX taskqueue */ + rsu_start(sc); + return (0); } static void -rsu_start(struct rsu_softc *sc) +rsu_drain_mbufq(struct rsu_softc *sc) +{ + struct mbuf *m; + struct ieee80211_node *ni; + + RSU_ASSERT_LOCKED(sc); + while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { + ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; + m->m_pkthdr.rcvif = NULL; + ieee80211_free_node(ni); + m_freem(m); + } +} + +static void +_rsu_start(struct rsu_softc *sc) { struct ieee80211_node *ni; struct rsu_data *bf; @@ -2012,6 +2191,8 @@ rsu_start(struct rsu_softc *sc) while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { bf = rsu_getbuf(sc); if (bf == NULL) { + RSU_DPRINTF(sc, RSU_DEBUG_TX, + "%s: failed to get buffer\n", __func__); mbufq_prepend(&sc->sc_snd, m); break; } @@ -2020,6 +2201,8 @@ rsu_start(struct rsu_softc *sc) m->m_pkthdr.rcvif = NULL; if (rsu_tx_start(sc, ni, m, bf) != 0) { + RSU_DPRINTF(sc, RSU_DEBUG_TX, + "%s: failed to transmit\n", __func__); if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); rsu_freebuf(sc, bf); @@ -2030,6 +2213,13 @@ rsu_start(struct rsu_softc *sc) } static void +rsu_start(struct rsu_softc *sc) +{ + + taskqueue_enqueue(taskqueue_thread, &sc->tx_task); +} + +static void rsu_parent(struct ieee80211com *ic) { struct rsu_softc *sc = ic->ic_softc; @@ -2279,6 +2469,9 @@ rsu_power_off(struct rsu_softc *sc) /* Disable 1.6V LDO. */ rsu_write_1(sc, R92S_SPS0_CTRL + 0, 0x56); rsu_write_1(sc, R92S_SPS0_CTRL + 1, 0x43); + + /* Firmware - tell it to switch things off */ + (void) rsu_set_fw_power_state(sc, RSU_PWR_OFF); } static int @@ -2329,7 +2522,7 @@ rsu_load_firmware(struct rsu_softc *sc) int ntries, error; if (rsu_read_1(sc, R92S_TCR) & R92S_TCR_FWRDY) { - RSU_DPRINTF(sc, RSU_DEBUG_FW | RSU_DEBUG_RESET, + RSU_DPRINTF(sc, RSU_DEBUG_ANY, "%s: Firmware already loaded\n", __func__); return (0); @@ -2453,6 +2646,7 @@ rsu_load_firmware(struct rsu_softc *sc) memset(dmem, 0, sizeof(*dmem)); dmem->hci_sel = R92S_HCI_SEL_USB | R92S_HCI_SEL_8172; dmem->nendpoints = sc->sc_nendpoints; + dmem->chip_version = sc->cut; /* XXX TODO: rf_config should come from ROM */ dmem->rf_config = 0x11; /* 1T1R */ dmem->vcs_type = R92S_VCS_TYPE_AUTO; @@ -2463,6 +2657,8 @@ rsu_load_firmware(struct rsu_softc *sc) dmem->ampdu_en = !! (sc->sc_ht); dmem->agg_offload = !! (sc->sc_ht); dmem->qos_en = 1; + dmem->ps_offload = 1; + dmem->lowpower_mode = 1; /* XXX TODO: configurable? */ /* Load DMEM section. */ error = rsu_fw_loadsection(sc, (uint8_t *)dmem, sizeof(*dmem)); if (error != 0) { @@ -2539,15 +2735,20 @@ rsu_init(struct rsu_softc *sc) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); uint8_t macaddr[IEEE80211_ADDR_LEN]; - struct r92s_set_pwr_mode cmd; int error; int i; RSU_ASSERT_LOCKED(sc); + /* Ensure the mbuf queue is drained */ + rsu_drain_mbufq(sc); + /* Init host async commands ring. */ sc->cmdq.cur = sc->cmdq.next = sc->cmdq.queued = 0; + /* Reset power management state. */ + rsu_write_1(sc, R92S_USB_HRPWM, 0); + /* Power on adapter. */ if (sc->cut == 1) rsu_power_on_acut(sc); @@ -2600,15 +2801,9 @@ rsu_init(struct rsu_softc *sc) goto fail; } - rsu_write_1(sc, R92S_USB_HRPWM, - R92S_USB_HRPWM_PS_ST_ACTIVE | R92S_USB_HRPWM_PS_ALL_ON); - /* Set PS mode fully active */ - memset(&cmd, 0, sizeof(cmd)); - cmd.mode = R92S_PS_MODE_ACTIVE; - RSU_DPRINTF(sc, RSU_DEBUG_RESET, "%s: setting ps mode to %d\n", - __func__, cmd.mode); - error = rsu_fw_cmd(sc, R92S_CMD_SET_PWR_MODE, &cmd, sizeof(cmd)); + error = rsu_set_fw_power_state(sc, RSU_PWR_ACTIVE); + if (error != 0) { device_printf(sc->sc_dev, "could not set PS mode\n"); goto fail; @@ -2645,15 +2840,21 @@ rsu_stop(struct rsu_softc *sc) { int i; + RSU_ASSERT_LOCKED(sc); + sc->sc_running = 0; sc->sc_calibrating = 0; taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL); + taskqueue_cancel(taskqueue_thread, &sc->tx_task, NULL); /* Power off adapter. */ rsu_power_off(sc); for (i = 0; i < RSU_N_TRANSFER; i++) usbd_transfer_stop(sc->sc_xfer[i]); + + /* Ensure the mbuf queue is drained */ + rsu_drain_mbufq(sc); } /* diff --git a/sys/dev/usb/wlan/if_rsureg.h b/sys/dev/usb/wlan/if_rsureg.h index debff0a..4929c80 100644 --- a/sys/dev/usb/wlan/if_rsureg.h +++ b/sys/dev/usb/wlan/if_rsureg.h @@ -599,6 +599,10 @@ struct r92s_add_ba_event { uint8_t tid; }; +struct r92s_add_ba_req { + uint32_t tid; +}; + /* * Driver definitions. */ @@ -720,7 +724,6 @@ struct rsu_data { struct rsu_vap { struct ieee80211vap vap; - struct ieee80211_beacon_offsets bo; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); @@ -740,10 +743,12 @@ struct rsu_softc { enum ieee80211_state, int); struct usbd_interface *sc_iface; struct timeout_task calib_task; + struct task tx_task; const uint8_t *qid2idx; struct mtx sc_mtx; int sc_ht; int sc_nendpoints; + int sc_curpwrstate; u_int sc_running:1, sc_calibrating:1, diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index 87088c1..c8707c4 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -4811,13 +4811,13 @@ static void run_update_beacon(struct ieee80211vap *vap, int item) { struct ieee80211com *ic = vap->iv_ic; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; + struct ieee80211_node *ni = vap->iv_bss; struct run_softc *sc = ic->ic_softc; struct run_vap *rvp = RUN_VAP(vap); int mcast = 0; uint32_t i; - KASSERT(vap != NULL, ("no beacon")); - switch (item) { case IEEE80211_BEACON_ERP: run_updateslot(ic); @@ -4832,14 +4832,13 @@ run_update_beacon(struct ieee80211vap *vap, int item) break; } - setbit(rvp->bo.bo_flags, item); + setbit(bo->bo_flags, item); if (rvp->beacon_mbuf == NULL) { - rvp->beacon_mbuf = ieee80211_beacon_alloc(vap->iv_bss, - &rvp->bo); + rvp->beacon_mbuf = ieee80211_beacon_alloc(ni, bo); if (rvp->beacon_mbuf == NULL) return; } - ieee80211_beacon_update(vap->iv_bss, &rvp->bo, rvp->beacon_mbuf, mcast); + ieee80211_beacon_update(ni, bo, rvp->beacon_mbuf, mcast); i = RUN_CMDQ_GET(&sc->cmdq_store); DPRINTF("cmdq_store=%d\n", i); @@ -4854,6 +4853,7 @@ static void run_update_beacon_cb(void *arg) { struct ieee80211vap *vap = arg; + struct ieee80211_node *ni = vap->iv_bss; struct run_vap *rvp = RUN_VAP(vap); struct ieee80211com *ic = vap->iv_ic; struct run_softc *sc = ic->ic_softc; @@ -4862,7 +4862,7 @@ run_update_beacon_cb(void *arg) uint16_t txwisize; uint8_t ridx; - if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC) + if (ni->ni_chan == IEEE80211_CHAN_ANYC) return; if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) return; @@ -4872,8 +4872,8 @@ run_update_beacon_cb(void *arg) * is taking care of apropriate calls. */ if (rvp->beacon_mbuf == NULL) { - rvp->beacon_mbuf = ieee80211_beacon_alloc(vap->iv_bss, - &rvp->bo); + rvp->beacon_mbuf = ieee80211_beacon_alloc(ni, + &vap->iv_bcn_off); if (rvp->beacon_mbuf == NULL) return; } diff --git a/sys/dev/usb/wlan/if_runvar.h b/sys/dev/usb/wlan/if_runvar.h index 71e29ba..bbefbb0 100644 --- a/sys/dev/usb/wlan/if_runvar.h +++ b/sys/dev/usb/wlan/if_runvar.h @@ -119,7 +119,6 @@ struct run_cmdq { struct run_vap { struct ieee80211vap vap; - struct ieee80211_beacon_offsets bo; struct mbuf *beacon_mbuf; int (*newstate)(struct ieee80211vap *, diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 04e09204..39fa71b 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -102,6 +102,7 @@ __FBSDID("$FreeBSD$"); #endif #include <net80211/ieee80211_var.h> +#include <net80211/ieee80211_input.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> @@ -156,15 +157,6 @@ enum { } while (0) #endif -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((u_int16_t) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((u_int32_t) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ - (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) - /* recognized device vendors/products */ static const STRUCT_USB_HOST_ID uath_devs[] = { #define UATH_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) } @@ -599,7 +591,6 @@ uath_dump_cmd(const uint8_t *buf, int len, char prefix) static const char * uath_codename(int code) { -#define N(a) (sizeof(a)/sizeof(a[0])) static const char *names[] = { "0x00", "HOST_AVAILABLE", @@ -662,13 +653,12 @@ uath_codename(int code) }; static char buf[8]; - if (code < N(names)) + if (code < nitems(names)) return names[code]; if (code == WDCMSG_SET_DEFAULT_KEY) return "SET_DEFAULT_KEY"; snprintf(buf, sizeof(buf), "0x%02x", code); return buf; -#undef N } #endif @@ -1486,7 +1476,7 @@ uath_wme_init(struct uath_softc *sc) qinfo.attr.aifs = htobe32(uath_wme_11g[ac].aifsn); qinfo.attr.logcwmin = htobe32(uath_wme_11g[ac].logcwmin); qinfo.attr.logcwmax = htobe32(uath_wme_11g[ac].logcwmax); - qinfo.attr.bursttime = htobe32(UATH_TXOP_TO_US( + qinfo.attr.bursttime = htobe32(IEEE80211_TXOP_TO_US( uath_wme_11g[ac].txop)); qinfo.attr.mode = htobe32(uath_wme_11g[ac].acm);/*XXX? */ qinfo.attr.qflags = htobe32(1); /* XXX? */ diff --git a/sys/dev/usb/wlan/if_uathvar.h b/sys/dev/usb/wlan/if_uathvar.h index 56b5ba3..4b4d9fc 100644 --- a/sys/dev/usb/wlan/if_uathvar.h +++ b/sys/dev/usb/wlan/if_uathvar.h @@ -102,7 +102,6 @@ struct uath_wme_settings { uint8_t logcwmin; uint8_t logcwmax; uint16_t txop; -#define UATH_TXOP_TO_US(txop) ((txop) << 5) uint8_t acm; }; diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 187a47a..bff4de5 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -713,7 +713,7 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) if (vap->iv_opmode == IEEE80211_M_HOSTAP || vap->iv_opmode == IEEE80211_M_IBSS) { - m = ieee80211_beacon_alloc(ni, &uvp->bo); + m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off); if (m == NULL) { device_printf(sc->sc_dev, "could not allocate beacon\n"); @@ -1929,7 +1929,6 @@ ural_read_eeprom(struct ural_softc *sc) static int ural_bbp_init(struct ural_softc *sc) { -#define N(a) ((int)(sizeof (a) / sizeof ((a)[0]))) int i, ntries; /* wait for BBP to be ready */ @@ -1945,7 +1944,7 @@ ural_bbp_init(struct ural_softc *sc) } /* initialize BBP registers to default values */ - for (i = 0; i < N(ural_def_bbp); i++) + for (i = 0; i < nitems(ural_def_bbp); i++) ural_bbp_write(sc, ural_def_bbp[i].reg, ural_def_bbp[i].val); #if 0 @@ -1958,7 +1957,6 @@ ural_bbp_init(struct ural_softc *sc) #endif return 0; -#undef N } static void @@ -2013,7 +2011,6 @@ ural_set_rxantenna(struct ural_softc *sc, int antenna) static void ural_init(struct ural_softc *sc) { -#define N(a) ((int)(sizeof (a) / sizeof ((a)[0]))) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); uint16_t tmp; @@ -2027,7 +2024,7 @@ ural_init(struct ural_softc *sc) ural_stop(sc); /* initialize MAC registers to default values */ - for (i = 0; i < N(ural_def_mac); i++) + for (i = 0; i < nitems(ural_def_mac); i++) ural_write(sc, ural_def_mac[i].reg, ural_def_mac[i].val); /* wait for BBP and RF to wake up (this can take a long time!) */ @@ -2086,7 +2083,6 @@ ural_init(struct ural_softc *sc) return; fail: ural_stop(sc); -#undef N } static void diff --git a/sys/dev/usb/wlan/if_uralvar.h b/sys/dev/usb/wlan/if_uralvar.h index f40f71d..5461e87 100644 --- a/sys/dev/usb/wlan/if_uralvar.h +++ b/sys/dev/usb/wlan/if_uralvar.h @@ -73,7 +73,7 @@ typedef STAILQ_HEAD(, ural_tx_data) ural_txdhead; struct ural_vap { struct ieee80211vap vap; - struct ieee80211_beacon_offsets bo; + struct usb_callout ratectl_ch; struct task ratectl_task; diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index f0d2674..040ba86 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -1093,7 +1093,6 @@ fail: static usb_error_t urtw_adapter_start_b(struct urtw_softc *sc) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) uint8_t data8; usb_error_t error; @@ -1176,7 +1175,6 @@ urtw_adapter_start_b(struct urtw_softc *sc) urtw_write16_m(sc, 0x1ec, 0x800); /* RX MAX SIZE */ fail: return (error); -#undef N } static usb_error_t @@ -1914,31 +1912,27 @@ fail: static uint16_t urtw_rate2rtl(uint32_t rate) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; - for (i = 0; i < N(urtw_ratetable); i++) { + for (i = 0; i < nitems(urtw_ratetable); i++) { if (rate == urtw_ratetable[i].reg) return urtw_ratetable[i].val; } return (3); -#undef N } static uint16_t urtw_rtl2rate(uint32_t rate) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; - for (i = 0; i < N(urtw_ratetable); i++) { + for (i = 0; i < nitems(urtw_ratetable); i++) { if (rate == urtw_ratetable[i].val) return urtw_ratetable[i].reg; } return (0); -#undef N } static usb_error_t @@ -2458,7 +2452,6 @@ fail: static usb_error_t urtw_8225_rf_init(struct urtw_softc *sc) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; uint16_t data; usb_error_t error; @@ -2489,7 +2482,7 @@ urtw_8225_rf_init(struct urtw_softc *sc) goto fail; usb_pause_mtx(&sc->sc_mtx, 1000); - for (i = 0; i < N(urtw_8225_rf_part1); i++) { + for (i = 0; i < nitems(urtw_8225_rf_part1); i++) { urtw_8225_write(sc, urtw_8225_rf_part1[i].reg, urtw_8225_rf_part1[i].val); usb_pause_mtx(&sc->sc_mtx, 1); @@ -2521,7 +2514,7 @@ urtw_8225_rf_init(struct urtw_softc *sc) usb_pause_mtx(&sc->sc_mtx, 1); } - for (i = 0; i < N(urtw_8225_rf_part2); i++) { + for (i = 0; i < nitems(urtw_8225_rf_part2); i++) { urtw_8187_write_phy_ofdm(sc, urtw_8225_rf_part2[i].reg, urtw_8225_rf_part2[i].val); usb_pause_mtx(&sc->sc_mtx, 1); @@ -2531,7 +2524,7 @@ urtw_8225_rf_init(struct urtw_softc *sc) if (error) goto fail; - for (i = 0; i < N(urtw_8225_rf_part3); i++) { + for (i = 0; i < nitems(urtw_8225_rf_part3); i++) { urtw_8187_write_phy_cck(sc, urtw_8225_rf_part3[i].reg, urtw_8225_rf_part3[i].val); usb_pause_mtx(&sc->sc_mtx, 1); @@ -2557,7 +2550,6 @@ urtw_8225_rf_init(struct urtw_softc *sc) error = urtw_8225_rf_set_chan(sc, 1); fail: return (error); -#undef N } static usb_error_t @@ -2841,7 +2833,6 @@ fail: static usb_error_t urtw_8225v2_rf_init(struct urtw_softc *sc) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int i; uint16_t data; uint32_t data32; @@ -2874,7 +2865,7 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) usb_pause_mtx(&sc->sc_mtx, 500); - for (i = 0; i < N(urtw_8225v2_rf_part1); i++) { + for (i = 0; i < nitems(urtw_8225v2_rf_part1); i++) { urtw_8225_write(sc, urtw_8225v2_rf_part1[i].reg, urtw_8225v2_rf_part1[i].val); } @@ -2929,7 +2920,7 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) urtw_8187_write_phy_ofdm(sc, 0xa, (uint8_t)i + 0x80); } - for (i = 0; i < N(urtw_8225v2_rf_part2); i++) { + for (i = 0; i < nitems(urtw_8225v2_rf_part2); i++) { urtw_8187_write_phy_ofdm(sc, urtw_8225v2_rf_part2[i].reg, urtw_8225v2_rf_part2[i].val); } @@ -2938,7 +2929,7 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) if (error) goto fail; - for (i = 0; i < N(urtw_8225v2_rf_part3); i++) { + for (i = 0; i < nitems(urtw_8225v2_rf_part3); i++) { urtw_8187_write_phy_cck(sc, urtw_8225v2_rf_part3[i].reg, urtw_8225v2_rf_part3[i].val); } @@ -2961,7 +2952,6 @@ urtw_8225v2_rf_init(struct urtw_softc *sc) error = urtw_8225_rf_set_chan(sc, 1); fail: return (error); -#undef N } static usb_error_t @@ -3329,7 +3319,6 @@ urtw_8225v2b_rf_init(struct urtw_softc *sc) fail: return (error); -#undef N } static usb_error_t diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 457a885..42365d1 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/ip.h> #include <net80211/ieee80211_var.h> +#include <net80211/ieee80211_input.h> #include <net80211/ieee80211_regdomain.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_ratectl.h> @@ -83,8 +84,7 @@ SYSCTL_INT(_hw_usb_urtwn, OID_AUTO, debug, CTLFLAG_RWTUN, &urtwn_debug, 0, #endif #define URTWN_RSSI(r) (r) - 110 -#define IEEE80211_HAS_ADDR4(wh) \ - (((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) +#define IEEE80211_HAS_ADDR4(wh) IEEE80211_IS_DSTODS(wh) /* various supported device vendors/products */ static const STRUCT_USB_HOST_ID urtwn_devs[] = { diff --git a/sys/dev/usb/wlan/if_urtwnreg.h b/sys/dev/usb/wlan/if_urtwnreg.h index 3c21279..ece356d 100644 --- a/sys/dev/usb/wlan/if_urtwnreg.h +++ b/sys/dev/usb/wlan/if_urtwnreg.h @@ -801,10 +801,6 @@ #define R92C_RAID_11B 6 -/* Macros to access unaligned little-endian memory. */ -#define LE_READ_2(x) ((x)[0] | (x)[1] << 8) -#define LE_READ_4(x) ((x)[0] | (x)[1] << 8 | (x)[2] << 16 | (x)[3] << 24) - /* * Macros to access subfields in registers. */ @@ -1138,7 +1134,6 @@ struct urtwn_fw_info { struct urtwn_vap { struct ieee80211vap vap; - struct ieee80211_beacon_offsets bo; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c index a86ab8a..5a59d37 100644 --- a/sys/dev/usb/wlan/if_zyd.c +++ b/sys/dev/usb/wlan/if_zyd.c @@ -930,25 +930,23 @@ fail: static int zyd_rfmd_init(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_RFMD_PHY; static const uint32_t rfini[] = ZYD_RFMD_RF; int i, error; /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) { + for (i = 0; i < nitems(phyini); i++) { zyd_write16_m(sc, phyini[i].reg, phyini[i].val); } /* init RFMD radio */ - for (i = 0; i < N(rfini); i++) { + for (i = 0; i < nitems(rfini); i++) { if ((error = zyd_rfwrite(sc, rfini[i])) != 0) return (error); } fail: return (error); -#undef N } static int @@ -989,7 +987,6 @@ fail: static int zyd_al2230_init(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY; static const struct zyd_phy_pair phy2230s[] = ZYD_AL2230S_PHY_INIT; @@ -1003,16 +1000,16 @@ zyd_al2230_init(struct zyd_rf *rf) int i, error; /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) + for (i = 0; i < nitems(phyini); i++) zyd_write16_m(sc, phyini[i].reg, phyini[i].val); if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) { - for (i = 0; i < N(phy2230s); i++) + for (i = 0; i < nitems(phy2230s); i++) zyd_write16_m(sc, phy2230s[i].reg, phy2230s[i].val); } /* init AL2230 radio */ - for (i = 0; i < N(rfini1); i++) { + for (i = 0; i < nitems(rfini1); i++) { error = zyd_rfwrite(sc, rfini1[i]); if (error != 0) goto fail; @@ -1025,34 +1022,32 @@ zyd_al2230_init(struct zyd_rf *rf) if (error != 0) goto fail; - for (i = 0; i < N(rfini2); i++) { + for (i = 0; i < nitems(rfini2); i++) { error = zyd_rfwrite(sc, rfini2[i]); if (error != 0) goto fail; } - for (i = 0; i < N(phypll); i++) + for (i = 0; i < nitems(phypll); i++) zyd_write16_m(sc, phypll[i].reg, phypll[i].val); - for (i = 0; i < N(rfini3); i++) { + for (i = 0; i < nitems(rfini3); i++) { error = zyd_rfwrite(sc, rfini3[i]); if (error != 0) goto fail; } fail: return (error); -#undef N } static int zyd_al2230_fini(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy[] = ZYD_AL2230_PHY_FINI_PART1; - for (i = 0; i < N(phy); i++) + for (i = 0; i < nitems(phy); i++) zyd_write16_m(sc, phy[i].reg, phy[i].val); if (sc->sc_newphy != 0) @@ -1061,13 +1056,11 @@ zyd_al2230_fini(struct zyd_rf *rf) zyd_write16_m(sc, ZYD_CR203, 0x6); fail: return (error); -#undef N } static int zyd_al2230_init_b(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy1[] = ZYD_AL2230_PHY_PART1; static const struct zyd_phy_pair phy2[] = ZYD_AL2230_PHY_PART2; @@ -1080,15 +1073,15 @@ zyd_al2230_init_b(struct zyd_rf *rf) static const uint32_t zyd_al2230_chtable[][3] = ZYD_AL2230_CHANTABLE; int i, error; - for (i = 0; i < N(phy1); i++) + for (i = 0; i < nitems(phy1); i++) zyd_write16_m(sc, phy1[i].reg, phy1[i].val); /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) + for (i = 0; i < nitems(phyini); i++) zyd_write16_m(sc, phyini[i].reg, phyini[i].val); if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) { - for (i = 0; i < N(phy2230s); i++) + for (i = 0; i < nitems(phy2230s); i++) zyd_write16_m(sc, phy2230s[i].reg, phy2230s[i].val); } @@ -1098,7 +1091,7 @@ zyd_al2230_init_b(struct zyd_rf *rf) return (error); } - for (i = 0; i < N(rfini_part1); i++) { + for (i = 0; i < nitems(rfini_part1); i++) { error = zyd_rfwrite_cr(sc, rfini_part1[i]); if (error != 0) return (error); @@ -1111,28 +1104,27 @@ zyd_al2230_init_b(struct zyd_rf *rf) if (error != 0) goto fail; - for (i = 0; i < N(rfini_part2); i++) { + for (i = 0; i < nitems(rfini_part2); i++) { error = zyd_rfwrite_cr(sc, rfini_part2[i]); if (error != 0) return (error); } - for (i = 0; i < N(phy2); i++) + for (i = 0; i < nitems(phy2); i++) zyd_write16_m(sc, phy2[i].reg, phy2[i].val); - for (i = 0; i < N(rfini_part3); i++) { + for (i = 0; i < nitems(rfini_part3); i++) { error = zyd_rfwrite_cr(sc, rfini_part3[i]); if (error != 0) return (error); } - for (i = 0; i < N(phy3); i++) + for (i = 0; i < nitems(phy3); i++) zyd_write16_m(sc, phy3[i].reg, phy3[i].val); error = zyd_al2230_fini(rf); fail: return (error); -#undef N } static int @@ -1150,7 +1142,6 @@ fail: static int zyd_al2230_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy1[] = { @@ -1170,17 +1161,15 @@ zyd_al2230_set_channel(struct zyd_rf *rf, uint8_t chan) if (error != 0) goto fail; - for (i = 0; i < N(phy1); i++) + for (i = 0; i < nitems(phy1); i++) zyd_write16_m(sc, phy1[i].reg, phy1[i].val); fail: return (error); -#undef N } static int zyd_al2230_set_channel_b(struct zyd_rf *rf, uint8_t chan) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phy1[] = ZYD_AL2230_PHY_PART1; @@ -1188,7 +1177,7 @@ zyd_al2230_set_channel_b(struct zyd_rf *rf, uint8_t chan) uint32_t r1, r2, r3; } rfprog[] = ZYD_AL2230_CHANTABLE_B; - for (i = 0; i < N(phy1); i++) + for (i = 0; i < nitems(phy1); i++) zyd_write16_m(sc, phy1[i].reg, phy1[i].val); error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r1); @@ -1203,7 +1192,6 @@ zyd_al2230_set_channel_b(struct zyd_rf *rf, uint8_t chan) error = zyd_al2230_fini(rf); fail: return (error); -#undef N } #define ZYD_AL2230_PHY_BANDEDGE6 \ @@ -1215,7 +1203,6 @@ fail: static int zyd_al2230_bandedge6(struct zyd_rf *rf, struct ieee80211_channel *c) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error = 0, i; struct zyd_softc *sc = rf->rf_sc; struct ieee80211com *ic = &sc->sc_ic; @@ -1225,11 +1212,10 @@ zyd_al2230_bandedge6(struct zyd_rf *rf, struct ieee80211_channel *c) if (chan == 1 || chan == 11) r[0].val = 0x12; - for (i = 0; i < N(r); i++) + for (i = 0; i < nitems(r); i++) zyd_write16_m(sc, r[i].reg, r[i].val); fail: return (error); -#undef N } /* @@ -1238,7 +1224,6 @@ fail: static int zyd_al7230B_init(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini_1[] = ZYD_AL7230B_PHY_1; static const struct zyd_phy_pair phyini_2[] = ZYD_AL7230B_PHY_2; @@ -1250,29 +1235,28 @@ zyd_al7230B_init(struct zyd_rf *rf) /* for AL7230B, PHY and RF need to be initialized in "phases" */ /* init RF-dependent PHY registers, part one */ - for (i = 0; i < N(phyini_1); i++) + for (i = 0; i < nitems(phyini_1); i++) zyd_write16_m(sc, phyini_1[i].reg, phyini_1[i].val); /* init AL7230B radio, part one */ - for (i = 0; i < N(rfini_1); i++) { + for (i = 0; i < nitems(rfini_1); i++) { if ((error = zyd_rfwrite(sc, rfini_1[i])) != 0) return (error); } /* init RF-dependent PHY registers, part two */ - for (i = 0; i < N(phyini_2); i++) + for (i = 0; i < nitems(phyini_2); i++) zyd_write16_m(sc, phyini_2[i].reg, phyini_2[i].val); /* init AL7230B radio, part two */ - for (i = 0; i < N(rfini_2); i++) { + for (i = 0; i < nitems(rfini_2); i++) { if ((error = zyd_rfwrite(sc, rfini_2[i])) != 0) return (error); } /* init RF-dependent PHY registers, part three */ - for (i = 0; i < N(phyini_3); i++) + for (i = 0; i < nitems(phyini_3); i++) zyd_write16_m(sc, phyini_3[i].reg, phyini_3[i].val); fail: return (error); -#undef N } static int @@ -1290,7 +1274,6 @@ fail: static int zyd_al7230B_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct { uint32_t r1, r2; @@ -1301,7 +1284,7 @@ zyd_al7230B_set_channel(struct zyd_rf *rf, uint8_t chan) zyd_write16_m(sc, ZYD_CR240, 0x57); zyd_write16_m(sc, ZYD_CR251, 0x2f); - for (i = 0; i < N(rfsc); i++) { + for (i = 0; i < nitems(rfsc); i++) { if ((error = zyd_rfwrite(sc, rfsc[i])) != 0) return (error); } @@ -1327,7 +1310,6 @@ zyd_al7230B_set_channel(struct zyd_rf *rf, uint8_t chan) zyd_write16_m(sc, ZYD_CR240, 0x08); fail: return (error); -#undef N } /* @@ -1336,7 +1318,6 @@ fail: static int zyd_al2210_init(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_AL2210_PHY; static const uint32_t rfini[] = ZYD_AL2210_RF; @@ -1346,11 +1327,11 @@ zyd_al2210_init(struct zyd_rf *rf) zyd_write32_m(sc, ZYD_CR18, 2); /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) + for (i = 0; i < nitems(phyini); i++) zyd_write16_m(sc, phyini[i].reg, phyini[i].val); /* init AL2210 radio */ - for (i = 0; i < N(rfini); i++) { + for (i = 0; i < nitems(rfini); i++) { if ((error = zyd_rfwrite(sc, rfini[i])) != 0) return (error); } @@ -1364,7 +1345,6 @@ zyd_al2210_init(struct zyd_rf *rf) zyd_write32_m(sc, ZYD_CR18, 3); fail: return (error); -#undef N } static int @@ -1409,7 +1389,6 @@ static int zyd_gct_init(struct zyd_rf *rf) { #define ZYD_GCT_INTR_REG 0x85c1 -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_GCT_PHY; static const uint32_t rfini[] = ZYD_GCT_RF; @@ -1418,11 +1397,11 @@ zyd_gct_init(struct zyd_rf *rf) uint16_t data; /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) + for (i = 0; i < nitems(phyini); i++) zyd_write16_m(sc, phyini[i].reg, phyini[i].val); /* init cgt radio */ - for (i = 0; i < N(rfini); i++) { + for (i = 0; i < nitems(rfini); i++) { if ((error = zyd_rfwrite(sc, rfini[i])) != 0) return (error); } @@ -1431,7 +1410,7 @@ zyd_gct_init(struct zyd_rf *rf) if (error != 0) return (error); - for (i = 0; i < (int)(N(vco) - 1); i++) { + for (i = 0; i < (int)(nitems(vco) - 1); i++) { error = zyd_gct_set_channel_synth(rf, 1, 0); if (error != 0) goto fail; @@ -1458,26 +1437,23 @@ zyd_gct_init(struct zyd_rf *rf) zyd_write16_m(sc, ZYD_CR203, 0x6); fail: return (error); -#undef N #undef ZYD_GCT_INTR_REG } static int zyd_gct_mode(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const uint32_t mode[] = { 0x25f98, 0x25f9a, 0x25f94, 0x27fd4 }; int i, error; - for (i = 0; i < N(mode); i++) { + for (i = 0; i < nitems(mode); i++) { if ((error = zyd_rfwrite(sc, mode[i])) != 0) break; } return (error); -#undef N } static int @@ -1524,7 +1500,6 @@ fail: static int zyd_gct_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) int error, i; struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair cmd[] = { @@ -1543,7 +1518,7 @@ zyd_gct_set_channel(struct zyd_rf *rf, uint8_t chan) error = zyd_gct_mode(rf); if (error != 0) return (error); - for (i = 0; i < N(cmd); i++) + for (i = 0; i < nitems(cmd); i++) zyd_write16_m(sc, cmd[i].reg, cmd[i].val); error = zyd_gct_txgain(rf, chan); if (error != 0) @@ -1551,25 +1526,22 @@ zyd_gct_set_channel(struct zyd_rf *rf, uint8_t chan) zyd_write16_m(sc, ZYD_CR203, 0x6); fail: return (error); -#undef N } static int zyd_gct_txgain(struct zyd_rf *rf, uint8_t chan) { -#define N(a) (sizeof(a) / sizeof((a)[0])) struct zyd_softc *sc = rf->rf_sc; static uint32_t txgain[] = ZYD_GCT_TXGAIN; uint8_t idx = sc->sc_pwrint[chan - 1]; - if (idx >= N(txgain)) { + if (idx >= nitems(txgain)) { device_printf(sc->sc_dev, "could not set TX gain (%d %#x)\n", chan, idx); return 0; } return zyd_rfwrite(sc, 0x700000 | txgain[idx]); -#undef N } /* @@ -1578,7 +1550,6 @@ zyd_gct_txgain(struct zyd_rf *rf, uint8_t chan) static int zyd_maxim2_init(struct zyd_rf *rf) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY; static const uint32_t rfini[] = ZYD_MAXIM2_RF; @@ -1586,14 +1557,14 @@ zyd_maxim2_init(struct zyd_rf *rf) int i, error; /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) + for (i = 0; i < nitems(phyini); i++) zyd_write16_m(sc, phyini[i].reg, phyini[i].val); zyd_read16_m(sc, ZYD_CR203, &tmp); zyd_write16_m(sc, ZYD_CR203, tmp & ~(1 << 4)); /* init maxim2 radio */ - for (i = 0; i < N(rfini); i++) { + for (i = 0; i < nitems(rfini); i++) { if ((error = zyd_rfwrite(sc, rfini[i])) != 0) return (error); } @@ -1601,7 +1572,6 @@ zyd_maxim2_init(struct zyd_rf *rf) zyd_write16_m(sc, ZYD_CR203, tmp | (1 << 4)); fail: return (error); -#undef N } static int @@ -1615,7 +1585,6 @@ zyd_maxim2_switch_radio(struct zyd_rf *rf, int on) static int zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan) { -#define N(a) ((int)(sizeof(a) / sizeof((a)[0]))) struct zyd_softc *sc = rf->rf_sc; static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY; static const uint32_t rfini[] = ZYD_MAXIM2_RF; @@ -1631,7 +1600,7 @@ zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan) */ /* init RF-dependent PHY registers */ - for (i = 0; i < N(phyini); i++) + for (i = 0; i < nitems(phyini); i++) zyd_write16_m(sc, phyini[i].reg, phyini[i].val); zyd_read16_m(sc, ZYD_CR203, &tmp); @@ -1646,7 +1615,7 @@ zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan) goto fail; /* init maxim2 radio - skipping the two first values */ - for (i = 2; i < N(rfini); i++) { + for (i = 2; i < nitems(rfini); i++) { if ((error = zyd_rfwrite(sc, rfini[i])) != 0) return (error); } @@ -1654,7 +1623,6 @@ zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan) zyd_write16_m(sc, ZYD_CR203, tmp | (1 << 4)); fail: return (error); -#undef N } static int diff --git a/sys/dev/wi/if_wivar.h b/sys/dev/wi/if_wivar.h index 9b668cc..8cc320d 100644 --- a/sys/dev/wi/if_wivar.h +++ b/sys/dev/wi/if_wivar.h @@ -58,7 +58,6 @@ struct wi_vap { struct ieee80211vap wv_vap; - struct ieee80211_beacon_offsets wv_bo; void (*wv_recv_mgmt)(struct ieee80211_node *, struct mbuf *, int, const struct ieee80211_rx_stats *rxs, int, int); diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index 01ce3e4..e77d42d 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -4309,8 +4309,9 @@ wpi_auth(struct wpi_softc *sc, struct ieee80211vap *vap) static int wpi_config_beacon(struct wpi_vap *wvp) { - struct ieee80211com *ic = wvp->wv_vap.iv_ic; - struct ieee80211_beacon_offsets *bo = &wvp->wv_boff; + struct ieee80211vap *vap = &wvp->wv_vap; + struct ieee80211com *ic = vap->iv_ic; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; struct wpi_buf *bcn = &wvp->wv_bcbuf; struct wpi_softc *sc = ic->ic_softc; struct wpi_cmd_beacon *cmd = (struct wpi_cmd_beacon *)&bcn->data; @@ -4361,9 +4362,10 @@ end: bcn->m = m; static int wpi_setup_beacon(struct wpi_softc *sc, struct ieee80211_node *ni) { - struct wpi_vap *wvp = WPI_VAP(ni->ni_vap); + struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; + struct wpi_vap *wvp = WPI_VAP(vap); struct wpi_buf *bcn = &wvp->wv_bcbuf; - struct ieee80211_beacon_offsets *bo = &wvp->wv_boff; struct mbuf *m; int error; @@ -4397,7 +4399,7 @@ wpi_update_beacon(struct ieee80211vap *vap, int item) struct wpi_softc *sc = vap->iv_ic->ic_softc; struct wpi_vap *wvp = WPI_VAP(vap); struct wpi_buf *bcn = &wvp->wv_bcbuf; - struct ieee80211_beacon_offsets *bo = &wvp->wv_boff; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; struct ieee80211_node *ni = vap->iv_bss; int mcast = 0; diff --git a/sys/dev/wpi/if_wpivar.h b/sys/dev/wpi/if_wpivar.h index 4e1baa5..0934eaa 100644 --- a/sys/dev/wpi/if_wpivar.h +++ b/sys/dev/wpi/if_wpivar.h @@ -125,7 +125,6 @@ struct wpi_vap { struct ieee80211vap wv_vap; struct wpi_buf wv_bcbuf; - struct ieee80211_beacon_offsets wv_boff; struct mtx wv_mtx; uint32_t wv_gtk; diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c index 526ce54..7c15c35 100644 --- a/sys/dev/wtap/if_wtap.c +++ b/sys/dev/wtap/if_wtap.c @@ -183,7 +183,7 @@ wtap_reset_vap(struct ieee80211vap *vap, u_long cmd) static void wtap_beacon_update(struct ieee80211vap *vap, int item) { - struct ieee80211_beacon_offsets *bo = &WTAP_VAP(vap)->av_boff; + struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; DWTAP_PRINTF("%s\n", __func__); setbit(bo->bo_flags, item); @@ -205,7 +205,7 @@ wtap_beacon_alloc(struct wtap_softc *sc, struct ieee80211_node *ni) * we assume the mbuf routines will return us something * with this alignment (perhaps should assert). */ - avp->beacon = ieee80211_beacon_alloc(ni, &avp->av_boff); + avp->beacon = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off); if (avp->beacon == NULL) { printf("%s: cannot get mbuf\n", __func__); return ENOMEM; @@ -242,7 +242,7 @@ wtap_beacon_intrp(void *arg) * of the TIM bitmap). */ m = m_dup(avp->beacon, M_NOWAIT); - if (ieee80211_beacon_update(avp->bf_node, &avp->av_boff, m, 0)) { + if (ieee80211_beacon_update(avp->bf_node, &vap->iv_bcn_off, m, 0)) { printf("%s, need to remap the memory because the beacon frame" " changed size.\n",__func__); } diff --git a/sys/dev/wtap/if_wtapvar.h b/sys/dev/wtap/if_wtapvar.h index 04a1818..5ba55cb 100644 --- a/sys/dev/wtap/if_wtapvar.h +++ b/sys/dev/wtap/if_wtapvar.h @@ -116,7 +116,6 @@ struct wtap_vap { struct wtap_medium *av_md; /* back pointer */ struct mbuf *beacon; /* beacon */ struct ieee80211_node *bf_node; /* pointer to the node */ - struct ieee80211_beacon_offsets av_boff;/* dynamic update state */ struct callout av_swba; /* software beacon alert */ uint32_t av_bcinterval; /* beacon interval */ void (*av_recv_mgmt)(struct ieee80211_node *, diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index e544bba..716faa3 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -64,6 +64,8 @@ struct fifoinfo { struct pipe *fi_pipe; long fi_readers; long fi_writers; + u_int fi_rgen; + u_int fi_wgen; }; static vop_print_t fifo_print; @@ -137,6 +139,7 @@ fifo_open(ap) struct thread *td; struct fifoinfo *fip; struct pipe *fpipe; + u_int gen; int error, stops_deferred; vp = ap->a_vp; @@ -164,6 +167,7 @@ fifo_open(ap) PIPE_LOCK(fpipe); if (ap->a_mode & FREAD) { fip->fi_readers++; + fip->fi_rgen++; if (fip->fi_readers == 1) { fpipe->pipe_state &= ~PIPE_EOF; if (fip->fi_writers > 0) @@ -179,6 +183,7 @@ fifo_open(ap) return (ENXIO); } fip->fi_writers++; + fip->fi_wgen++; if (fip->fi_writers == 1) { fpipe->pipe_state &= ~PIPE_EOF; if (fip->fi_readers > 0) @@ -187,6 +192,7 @@ fifo_open(ap) } if ((ap->a_mode & O_NONBLOCK) == 0) { if ((ap->a_mode & FREAD) && fip->fi_writers == 0) { + gen = fip->fi_wgen; VOP_UNLOCK(vp, 0); stops_deferred = sigallowstop(); error = msleep(&fip->fi_readers, PIPE_MTX(fpipe), @@ -194,7 +200,7 @@ fifo_open(ap) if (stops_deferred) sigdeferstop(); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - if (error) { + if (error != 0 && gen == fip->fi_wgen) { fip->fi_readers--; if (fip->fi_readers == 0) { PIPE_LOCK(fpipe); @@ -214,6 +220,7 @@ fifo_open(ap) */ } if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) { + gen = fip->fi_rgen; VOP_UNLOCK(vp, 0); stops_deferred = sigallowstop(); error = msleep(&fip->fi_writers, PIPE_MTX(fpipe), @@ -221,7 +228,7 @@ fifo_open(ap) if (stops_deferred) sigdeferstop(); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - if (error) { + if (error != 0 && gen == fip->fi_rgen) { fip->fi_writers--; if (fip->fi_writers == 0) { PIPE_LOCK(fpipe); diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 950cb0e..71c88e0 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1145,45 +1145,6 @@ callout_schedule(struct callout *c, int to_ticks) } int -callout_drain_async(struct callout *c, callout_func_t *func, void *arg) -{ - struct callout_cpu *cc; - struct lock_class *class; - int retval; - int direct; - - /* stop callout */ - callout_stop(c); - - /* check if callback is being called */ - cc = callout_lock(c); - if (c->c_iflags & CALLOUT_DIRECT) { - direct = 1; - } else { - direct = 0; - } - retval = (cc_exec_curr(cc, direct) == c); - - /* drop locks, if any */ - if (retval && c->c_lock != NULL && - c->c_lock != &Giant.lock_object) { - /* ensure we are properly locked */ - class = LOCK_CLASS(c->c_lock); - class->lc_assert(c->c_lock, LA_XLOCKED); - /* the final callback should not be called locked */ - c->c_lock = NULL; - c->c_iflags |= CALLOUT_RETURNUNLOCKED; - } - CC_UNLOCK(cc); - - /* check if we should queue final callback */ - if (retval) - callout_reset(c, 1, func, arg); - - return (retval); -} - -int _callout_stop_safe(struct callout *c, int safe) { struct callout_cpu *cc, *old_cc; diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 52c6f16..65fb3e7 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$"); #define NBUF 0 #endif #ifndef MAXFILES -#define MAXFILES (maxproc * 2) +#define MAXFILES (40 + 32 * maxusers) #endif static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS); @@ -253,6 +253,8 @@ init_param2(long physpages) TUNABLE_INT_FETCH("kern.maxproc", &maxproc); if (maxproc > (physpages / 12)) maxproc = physpages / 12; + if (maxproc > pid_max) + maxproc = pid_max; maxprocperuid = (maxproc * 9) / 10; /* diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index d675ff1..b6c295b 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -262,7 +262,7 @@ vfs_mountroot_devfs(struct thread *td, struct mount **mpp) return (error); } -static int +static void vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs) { struct nameidata nd; @@ -373,8 +373,6 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs) printf("mountroot: unable to unlink /dev/dev " "(error %d)\n", error); } - - return (0); } /* @@ -972,12 +970,10 @@ vfs_mountroot(void) while (!error) { error = vfs_mountroot_parse(sb, mp); if (!error) { - error = vfs_mountroot_shuffle(td, mp); - if (!error) { - sbuf_clear(sb); - error = vfs_mountroot_readconf(td, sb); - sbuf_finish(sb); - } + vfs_mountroot_shuffle(td, mp); + sbuf_clear(sb); + error = vfs_mountroot_readconf(td, sb); + sbuf_finish(sb); } } diff --git a/sys/libkern/arm/memclr.S b/sys/libkern/arm/memclr.S index b86b558..2883d3f 100644 --- a/sys/libkern/arm/memclr.S +++ b/sys/libkern/arm/memclr.S @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); * void bzero(dest, len) */ ENTRY_NP(__aeabi_memclr4) +EENTRY_NP(__aeabi_memclr8) b bzero +EEND(__aeabi_memclr8) END(__aeabi_memclr4) diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 64d0754..5bec9af 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -815,6 +815,7 @@ struct ieee80211_csa_ie { /* rate set entries are in .5 Mb/s units, and potentially marked as basic */ #define IEEE80211_RATE_BASIC 0x80 #define IEEE80211_RATE_VAL 0x7f +#define IEEE80211_RV(v) ((v) & IEEE80211_RATE_VAL) /* ERP information element flags */ #define IEEE80211_ERP_NON_ERP_PRESENT 0x01 diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c index 09c007a..b43bc07 100644 --- a/sys/net80211/ieee80211_ht.c +++ b/sys/net80211/ieee80211_ht.c @@ -1415,12 +1415,6 @@ ieee80211_ht_timeout(struct ieee80211com *ic) } } -/* unalligned little endian access */ -#define LE_READ_2(p) \ - ((uint16_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8))) - /* * Process an 802.11n HT capabilities ie. */ @@ -1833,6 +1827,55 @@ ieee80211_addba_request(struct ieee80211_node *ni, } /* + * Called by drivers that wish to request an ADDBA session be + * setup. This brings it up and starts the request timer. + */ +int +ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid) +{ + struct ieee80211_tx_ampdu *tap; + + if (tid < 0 || tid > 15) + return (0); + tap = &ni->ni_tx_ampdu[tid]; + + /* XXX locking */ + if ((tap->txa_flags & IEEE80211_AGGR_SETUP) == 0) { + /* do deferred setup of state */ + ampdu_tx_setup(tap); + } + /* XXX hack for not doing proper locking */ + tap->txa_flags &= ~IEEE80211_AGGR_NAK; + addba_start_timeout(tap); + return (1); +} + +/* + * Called by drivers that have marked a session as active. + */ +int +ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni, int tid, + int status) +{ + struct ieee80211_tx_ampdu *tap; + + if (tid < 0 || tid > 15) + return (0); + tap = &ni->ni_tx_ampdu[tid]; + + /* XXX locking */ + addba_stop_timeout(tap); + if (status == 1) { + tap->txa_flags |= IEEE80211_AGGR_RUNNING; + tap->txa_attempts = 0; + } else { + /* mark tid so we don't try again */ + tap->txa_flags |= IEEE80211_AGGR_NAK; + } + return (1); +} + +/* * Default method for processing an A-MPDU tx aggregation * response. We shutdown any pending timer and update the * state block according to the reply. diff --git a/sys/net80211/ieee80211_ht.h b/sys/net80211/ieee80211_ht.h index f7ba6c6..f099ffe 100644 --- a/sys/net80211/ieee80211_ht.h +++ b/sys/net80211/ieee80211_ht.h @@ -202,5 +202,8 @@ void ieee80211_ht_update_beacon(struct ieee80211vap *, struct ieee80211_beacon_offsets *); int ieee80211_ampdu_rx_start_ext(struct ieee80211_node *ni, int tid, int seq, int baw); +int ieee80211_ampdu_tx_request_ext(struct ieee80211_node *ni, int tid); +int ieee80211_ampdu_tx_request_active_ext(struct ieee80211_node *ni, + int tid, int status); #endif /* _NET80211_IEEE80211_HT_H_ */ diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c index ef81184..cb6ab81 100644 --- a/sys/net80211/ieee80211_mesh.c +++ b/sys/net80211/ieee80211_mesh.c @@ -434,13 +434,12 @@ mesh_rt_flush_invalid(struct ieee80211vap *vap) MESH_RT_UNLOCK(ms); } -#define N(a) (sizeof(a) / sizeof(a[0])) int ieee80211_mesh_register_proto_path(const struct ieee80211_mesh_proto_path *mpp) { int i, firstempty = -1; - for (i = 0; i < N(mesh_proto_paths); i++) { + for (i = 0; i < nitems(mesh_proto_paths); i++) { if (strncmp(mpp->mpp_descr, mesh_proto_paths[i].mpp_descr, IEEE80211_MESH_PROTO_DSZ) == 0) return EEXIST; @@ -460,7 +459,7 @@ ieee80211_mesh_register_proto_metric(const struct { int i, firstempty = -1; - for (i = 0; i < N(mesh_proto_metrics); i++) { + for (i = 0; i < nitems(mesh_proto_metrics); i++) { if (strncmp(mpm->mpm_descr, mesh_proto_metrics[i].mpm_descr, IEEE80211_MESH_PROTO_DSZ) == 0) return EEXIST; @@ -480,7 +479,7 @@ mesh_select_proto_path(struct ieee80211vap *vap, const char *name) struct ieee80211_mesh_state *ms = vap->iv_mesh; int i; - for (i = 0; i < N(mesh_proto_paths); i++) { + for (i = 0; i < nitems(mesh_proto_paths); i++) { if (strcasecmp(mesh_proto_paths[i].mpp_descr, name) == 0) { ms->ms_ppath = &mesh_proto_paths[i]; return 0; @@ -495,7 +494,7 @@ mesh_select_proto_metric(struct ieee80211vap *vap, const char *name) struct ieee80211_mesh_state *ms = vap->iv_mesh; int i; - for (i = 0; i < N(mesh_proto_metrics); i++) { + for (i = 0; i < nitems(mesh_proto_metrics); i++) { if (strcasecmp(mesh_proto_metrics[i].mpm_descr, name) == 0) { ms->ms_pmetric = &mesh_proto_metrics[i]; return 0; @@ -503,7 +502,6 @@ mesh_select_proto_metric(struct ieee80211vap *vap, const char *name) } return ENOENT; } -#undef N static void mesh_gatemode_setup(struct ieee80211vap *vap) diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index cbcf6b1..15188d8 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -491,7 +491,6 @@ int ieee80211_fix_rate(struct ieee80211_node *ni, struct ieee80211_rateset *nrs, int flags) { -#define RV(v) ((v) & IEEE80211_RATE_VAL) struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; int i, j, rix, error; @@ -545,7 +544,8 @@ ieee80211_fix_rate(struct ieee80211_node *ni, * Sort rates. */ for (j = i + 1; j < nrs->rs_nrates; j++) { - if (RV(nrs->rs_rates[i]) > RV(nrs->rs_rates[j])) { + if (IEEE80211_RV(nrs->rs_rates[i]) > + IEEE80211_RV(nrs->rs_rates[j])) { r = nrs->rs_rates[i]; nrs->rs_rates[i] = nrs->rs_rates[j]; nrs->rs_rates[j] = r; @@ -604,8 +604,7 @@ ieee80211_fix_rate(struct ieee80211_node *ni, "ucastrate %x\n", __func__, fixedrate, ucastrate, flags); return badrate | IEEE80211_RATE_BASIC; } else - return RV(okrate); -#undef RV + return IEEE80211_RV(okrate); } /* diff --git a/sys/net80211/ieee80211_scan_sta.c b/sys/net80211/ieee80211_scan_sta.c index 709710c..ea922d7 100644 --- a/sys/net80211/ieee80211_scan_sta.c +++ b/sys/net80211/ieee80211_scan_sta.c @@ -737,12 +737,6 @@ sta_cancel(struct ieee80211_scan_state *ss, struct ieee80211vap *vap) return 0; } -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((uint16_t) \ - ((((const uint8_t *)(p))[0] ) | \ - (((const uint8_t *)(p))[1] << 8))) - /* * Demote any supplied 11g channel to 11b. There should * always be an 11b channel but we check anyway... @@ -876,7 +870,6 @@ static int check_rate(struct ieee80211vap *vap, const struct ieee80211_channel *chan, const struct ieee80211_scan_entry *se) { -#define RV(v) ((v) & IEEE80211_RATE_VAL) const struct ieee80211_rateset *srs; int i, j, nrs, r, okrate, badrate, fixedrate, ucastrate; const uint8_t *rs; @@ -891,7 +884,7 @@ check_rate(struct ieee80211vap *vap, const struct ieee80211_channel *chan, fixedrate = IEEE80211_FIXED_RATE_NONE; again: for (i = 0; i < nrs; i++) { - r = RV(rs[i]); + r = IEEE80211_RV(rs[i]); badrate = r; /* * Check any fixed rate is included. @@ -902,7 +895,7 @@ again: * Check against our supported rates. */ for (j = 0; j < srs->rs_nrates; j++) - if (r == RV(srs->rs_rates[j])) { + if (r == IEEE80211_RV(srs->rs_rates[j])) { if (r > okrate) /* NB: track max */ okrate = r; break; @@ -928,8 +921,7 @@ back: if (okrate == 0 || ucastrate != fixedrate) return badrate | IEEE80211_RATE_BASIC; else - return RV(okrate); -#undef RV + return IEEE80211_RV(okrate); } static __inline int diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index a450701..8438d45 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -417,6 +417,7 @@ struct ieee80211vap { int iv_amsdu_limit; /* A-MSDU tx limit (bytes) */ u_int iv_ampdu_mintraffic[WME_NUM_AC]; + struct ieee80211_beacon_offsets iv_bcn_off; uint32_t *iv_aid_bitmap; /* association id map */ uint16_t iv_max_aid; uint16_t iv_sta_assoc; /* stations associated */ diff --git a/sys/netinet/toecore.c b/sys/netinet/toecore.c index 28ef32a..b690341 100644 --- a/sys/netinet/toecore.c +++ b/sys/netinet/toecore.c @@ -468,7 +468,6 @@ restart: lle = nd6_alloc(&sin6->sin6_addr, 0, ifp); if (lle == NULL) return (ENOMEM); /* Couldn't create entry in cache. */ - lle->ln_state = ND6_LLINFO_INCOMPLETE; IF_AFDATA_WLOCK(ifp); LLE_WLOCK(lle); lle_tmp = nd6_lookup(&sin6->sin6_addr, ND6_EXCLUSIVE, ifp); @@ -478,8 +477,7 @@ restart: IF_AFDATA_WUNLOCK(ifp); if (lle_tmp == NULL) { /* Arm timer for newly-created entry and send NS */ - nd6_llinfo_settimer_locked(lle, - (long)ND_IFINFO(ifp)->retrans * hz / 1000); + nd6_llinfo_setstate(lle, ND6_LLINFO_INCOMPLETE); LLE_WUNLOCK(lle); nd6_ns_output(ifp, NULL, NULL, &sin6->sin6_addr, 0); @@ -503,8 +501,7 @@ restart: LLE_WLOCK_ASSERT(lle); lle->la_asked = 0; - lle->ln_state = ND6_LLINFO_DELAY; - nd6_llinfo_settimer_locked(lle, (long)V_nd6_delay * hz); + nd6_llinfo_setstate(lle, ND6_LLINFO_DELAY); } if (lle->la_flags & LLE_VALID) { diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index cf97302..7ede15e 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -539,6 +539,44 @@ nd6_llinfo_get_holdsrc(struct llentry *ln, struct in6_addr *src) return (src); } +/* + * Switch @lle state to new state optionally arming timers. + */ +void +nd6_llinfo_setstate(struct llentry *lle, int newstate) +{ + struct ifnet *ifp; + long delay; + + delay = 0; + + switch (newstate) { + case ND6_LLINFO_INCOMPLETE: + ifp = lle->lle_tbl->llt_ifp; + delay = (long)ND_IFINFO(ifp)->retrans * hz / 1000; + break; + case ND6_LLINFO_REACHABLE: + if (!ND6_LLINFO_PERMANENT(lle)) { + ifp = lle->lle_tbl->llt_ifp; + delay = (long)ND_IFINFO(ifp)->reachable * hz; + } + break; + case ND6_LLINFO_STALE: + delay = (long)V_nd6_gctimer * hz; + break; + case ND6_LLINFO_DELAY: + lle->la_asked = 0; + delay = (long)V_nd6_delay * hz; + break; + } + + if (delay > 0) + nd6_llinfo_settimer_locked(lle, delay); + + lle->ln_state = newstate; +} + + void nd6_llinfo_settimer(struct llentry *ln, long tick) { @@ -638,10 +676,8 @@ nd6_llinfo_timer(void *arg) } break; case ND6_LLINFO_REACHABLE: - if (!ND6_LLINFO_PERMANENT(ln)) { - ln->ln_state = ND6_LLINFO_STALE; - nd6_llinfo_settimer_locked(ln, (long)V_nd6_gctimer * hz); - } + if (!ND6_LLINFO_PERMANENT(ln)) + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); break; case ND6_LLINFO_STALE: @@ -657,12 +693,10 @@ nd6_llinfo_timer(void *arg) if (ndi && (ndi->flags & ND6_IFF_PERFORMNUD) != 0) { /* We need NUD */ ln->la_asked = 1; - ln->ln_state = ND6_LLINFO_PROBE; + nd6_llinfo_setstate(ln, ND6_LLINFO_PROBE); send_ns = 1; - } else { - ln->ln_state = ND6_LLINFO_STALE; /* XXX */ - nd6_llinfo_settimer_locked(ln, (long)V_nd6_gctimer * hz); - } + } else + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); /* XXX */ break; case ND6_LLINFO_PROBE: if (ln->la_asked < V_nd6_umaxtries) { @@ -1316,11 +1350,7 @@ nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force) } } - ln->ln_state = ND6_LLINFO_REACHABLE; - if (!ND6_LLINFO_PERMANENT(ln)) { - nd6_llinfo_settimer_locked(ln, - (long)ND_IFINFO(rt->rt_ifp)->reachable * hz); - } + nd6_llinfo_setstate(ln, ND6_LLINFO_REACHABLE); done: LLE_WUNLOCK(ln); } @@ -1729,7 +1759,6 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, if (lladdr != NULL) { bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen); ln->la_flags |= LLE_VALID; - ln->ln_state = ND6_LLINFO_STALE; } IF_AFDATA_WLOCK(ifp); LLE_WLOCK(ln); @@ -1738,10 +1767,11 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, if (ln_tmp == NULL) lltable_link_entry(LLTABLE6(ifp), ln); IF_AFDATA_WUNLOCK(ifp); - if (ln_tmp == NULL) + if (ln_tmp == NULL) { /* No existing lle, mark as new entry */ is_newentry = 1; - else { + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); + } else { lltable_free_entry(LLTABLE6(ifp), ln); ln = ln_tmp; ln_tmp = NULL; @@ -1787,7 +1817,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, */ bcopy(lladdr, &ln->ll_addr, ifp->if_addrlen); ln->la_flags |= LLE_VALID; - ln->ln_state = ND6_LLINFO_STALE; + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED); @@ -1890,9 +1920,7 @@ nd6_grab_holdchain(struct llentry *ln, struct mbuf **chain, * detection on expiration. * (RFC 2461 7.3.3) */ - ln->la_asked = 0; - ln->ln_state = ND6_LLINFO_DELAY; - nd6_llinfo_settimer_locked(ln, (long)V_nd6_delay * hz); + nd6_llinfo_setstate(ln, ND6_LLINFO_DELAY); } } @@ -2032,6 +2060,8 @@ nd6_resolve_slow(struct ifnet *ifp, struct mbuf *m, const struct sockaddr_in6 *dst, u_char *desten, uint32_t *pflags) { struct llentry *lle = NULL, *lle_tmp; + struct in6_addr *psrc, src; + int send_ns; /* * Address resolution or Neighbor Unreachability Detection @@ -2059,7 +2089,6 @@ nd6_resolve_slow(struct ifnet *ifp, struct mbuf *m, m_freem(m); return (ENOBUFS); } - lle->ln_state = ND6_LLINFO_NOSTATE; IF_AFDATA_WLOCK(ifp); LLE_WLOCK(lle); @@ -2095,11 +2124,8 @@ nd6_resolve_slow(struct ifnet *ifp, struct mbuf *m, * neighbor unreachability detection on expiration. * (RFC 2461 7.3.3) */ - if (lle->ln_state == ND6_LLINFO_STALE) { - lle->la_asked = 0; - lle->ln_state = ND6_LLINFO_DELAY; - nd6_llinfo_settimer_locked(lle, (long)V_nd6_delay * hz); - } + if (lle->ln_state == ND6_LLINFO_STALE) + nd6_llinfo_setstate(lle, ND6_LLINFO_DELAY); /* * If the neighbor cache entry has a state other than INCOMPLETE @@ -2121,8 +2147,6 @@ nd6_resolve_slow(struct ifnet *ifp, struct mbuf *m, * does not exceed nd6_maxqueuelen. When it exceeds nd6_maxqueuelen, * the oldest packet in the queue will be removed. */ - if (lle->ln_state == ND6_LLINFO_NOSTATE) - lle->ln_state = ND6_LLINFO_INCOMPLETE; if (lle->la_hold != NULL) { struct mbuf *m_hold; @@ -2149,20 +2173,22 @@ nd6_resolve_slow(struct ifnet *ifp, struct mbuf *m, /* * If there has been no NS for the neighbor after entering the * INCOMPLETE state, send the first solicitation. + * Note that for newly-created lle la_asked will be 0, + * so we will transition from ND6_LLINFO_NOSTATE to + * ND6_LLINFO_INCOMPLETE state here. */ - if (!ND6_LLINFO_PERMANENT(lle) && lle->la_asked == 0) { - struct in6_addr src, *psrc; + psrc = NULL; + send_ns = 0; + if (lle->la_asked == 0) { lle->la_asked++; - - nd6_llinfo_settimer_locked(lle, - (long)ND_IFINFO(ifp)->retrans * hz / 1000); + send_ns = 1; psrc = nd6_llinfo_get_holdsrc(lle, &src); - LLE_WUNLOCK(lle); - nd6_ns_output(ifp, psrc, NULL, &dst->sin6_addr, NULL); - } else { - /* We did the lookup so we need to do the unlock here. */ - LLE_WUNLOCK(lle); + + nd6_llinfo_setstate(lle, ND6_LLINFO_INCOMPLETE); } + LLE_WUNLOCK(lle); + if (send_ns != 0) + nd6_ns_output(ifp, psrc, NULL, &dst->sin6_addr, NULL); return (EWOULDBLOCK); } diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 41df9e4..4765687 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -409,6 +409,7 @@ int nd6_options(union nd_opts *); struct llentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *); struct llentry *nd6_alloc(const struct in6_addr *, int, struct ifnet *); void nd6_setmtu(struct ifnet *); +void nd6_llinfo_setstate(struct llentry *lle, int newstate); void nd6_llinfo_settimer(struct llentry *, long); void nd6_llinfo_settimer_locked(struct llentry *, long); void nd6_timer(void *); diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 107fba2..1bcd531 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -769,16 +769,10 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) ln->la_flags |= LLE_VALID; EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED); if (is_solicited) { - ln->ln_state = ND6_LLINFO_REACHABLE; + nd6_llinfo_setstate(ln, ND6_LLINFO_REACHABLE); ln->ln_byhint = 0; - if (!ND6_LLINFO_PERMANENT(ln)) { - nd6_llinfo_settimer_locked(ln, - (long)ND_IFINFO(ln->lle_tbl->llt_ifp)->reachable * hz); - } - } else { - ln->ln_state = ND6_LLINFO_STALE; - nd6_llinfo_settimer_locked(ln, (long)V_nd6_gctimer * hz); - } + } else + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); if ((ln->ln_router = is_router) != 0) { /* * This means a router's state has changed from @@ -829,10 +823,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) * If state is REACHABLE, make it STALE. * no other updates should be done. */ - if (ln->ln_state == ND6_LLINFO_REACHABLE) { - ln->ln_state = ND6_LLINFO_STALE; - nd6_llinfo_settimer_locked(ln, (long)V_nd6_gctimer * hz); - } + if (ln->ln_state == ND6_LLINFO_REACHABLE) + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); goto freeit; } else if (is_override /* (2a) */ || (!is_override && (lladdr != NULL && !llchange)) /* (2b) */ @@ -853,18 +845,11 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) * changed, make it STALE. */ if (is_solicited) { - ln->ln_state = ND6_LLINFO_REACHABLE; ln->ln_byhint = 0; - if (!ND6_LLINFO_PERMANENT(ln)) { - nd6_llinfo_settimer_locked(ln, - (long)ND_IFINFO(ifp)->reachable * hz); - } + nd6_llinfo_setstate(ln, ND6_LLINFO_REACHABLE); } else { - if (lladdr != NULL && llchange) { - ln->ln_state = ND6_LLINFO_STALE; - nd6_llinfo_settimer_locked(ln, - (long)V_nd6_gctimer * hz); - } + if (lladdr != NULL && llchange) + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); } } diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 98790a8..375c00d 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -233,7 +233,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto) plen = ntohs(ip6->ip6_plen) - off + sizeof(*ip6); ulen = ntohs((u_short)uh->uh_ulen); - nxt = ip6->ip6_nxt; + nxt = proto; cscov_partial = (nxt == IPPROTO_UDPLITE) ? 1 : 0; if (nxt == IPPROTO_UDPLITE) { /* Zero means checksum over the complete packet. */ @@ -668,9 +668,11 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, return (error); } + nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? + IPPROTO_UDP : IPPROTO_UDPLITE; if (control) { if ((error = ip6_setpktopts(control, &opt, - inp->in6p_outputopts, td->td_ucred, IPPROTO_UDP)) != 0) + inp->in6p_outputopts, td->td_ucred, nxt)) != 0) goto release; optp = &opt; } else @@ -786,7 +788,7 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, * for UDP and IP6 headers. */ M_PREPEND(m, hlen + sizeof(struct udphdr), M_NOWAIT); - if (m == 0) { + if (m == NULL) { error = ENOBUFS; goto release; } @@ -794,8 +796,6 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, /* * Stuff checksum and output datagram. */ - nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? - IPPROTO_UDP : IPPROTO_UDPLITE; udp6 = (struct udphdr *)(mtod(m, caddr_t) + hlen); udp6->uh_sport = inp->inp_lport; /* lport is always set in the PCB */ udp6->uh_dport = fport; @@ -912,17 +912,21 @@ udp6_abort(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_abort: inp == NULL")); + INP_WLOCK(inp); #ifdef INET if (inp->inp_vflag & INP_IPV4) { struct pr_usrreqs *pru; + uint8_t nxt; - pru = inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs; + nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? + IPPROTO_UDP : IPPROTO_UDPLITE; + INP_WUNLOCK(inp); + pru = inetsw[ip_protox[nxt]].pr_usrreqs; (*pru->pru_abort)(so); return; } #endif - INP_WLOCK(inp); if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { INP_HASH_WLOCK(pcbinfo); in6_pcbdisconnect(inp); @@ -1036,16 +1040,20 @@ udp6_close(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_close: inp == NULL")); + INP_WLOCK(inp); #ifdef INET if (inp->inp_vflag & INP_IPV4) { struct pr_usrreqs *pru; + uint8_t nxt; - pru = inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs; + nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? + IPPROTO_UDP : IPPROTO_UDPLITE; + INP_WUNLOCK(inp); + pru = inetsw[ip_protox[nxt]].pr_usrreqs; (*pru->pru_disconnect)(so); return; } #endif - INP_WLOCK(inp); if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { INP_HASH_WLOCK(pcbinfo); in6_pcbdisconnect(inp); @@ -1151,18 +1159,21 @@ udp6_disconnect(struct socket *so) inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_disconnect: inp == NULL")); + INP_WLOCK(inp); #ifdef INET if (inp->inp_vflag & INP_IPV4) { struct pr_usrreqs *pru; + uint8_t nxt; - pru = inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs; + nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? + IPPROTO_UDP : IPPROTO_UDPLITE; + INP_WUNLOCK(inp); + pru = inetsw[ip_protox[nxt]].pr_usrreqs; (void)(*pru->pru_disconnect)(so); return (0); } #endif - INP_WLOCK(inp); - if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { error = ENOTCONN; goto out; @@ -1218,7 +1229,10 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, } if (hasv4addr) { struct pr_usrreqs *pru; + uint8_t nxt; + nxt = (inp->inp_socket->so_proto->pr_protocol == + IPPROTO_UDP) ? IPPROTO_UDP : IPPROTO_UDPLITE; /* * XXXRW: We release UDP-layer locks before calling * udp_send() in order to avoid recursion. However, @@ -1230,7 +1244,7 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, INP_WUNLOCK(inp); if (sin6) in6_sin6_2_sin_in_sock(addr); - pru = inetsw[ip_protox[IPPROTO_UDP]].pr_usrreqs; + pru = inetsw[ip_protox[nxt]].pr_usrreqs; /* addr will just be freed in sendit(). */ return ((*pru->pru_send)(so, flags, m, addr, control, td)); diff --git a/sys/sys/_callout.h b/sys/sys/_callout.h index 80fef2a..a9134c8 100644 --- a/sys/sys/_callout.h +++ b/sys/sys/_callout.h @@ -46,8 +46,6 @@ LIST_HEAD(callout_list, callout); SLIST_HEAD(callout_slist, callout); TAILQ_HEAD(callout_tailq, callout); -typedef void callout_func_t(void *); - struct callout { union { LIST_ENTRY(callout) le; diff --git a/sys/sys/callout.h b/sys/sys/callout.h index f2841e8..5e21164 100644 --- a/sys/sys/callout.h +++ b/sys/sys/callout.h @@ -82,7 +82,6 @@ struct callout_handle { #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) #define callout_drain(c) _callout_stop_safe(c, 1) -int callout_drain_async(struct callout *, callout_func_t *, void *); void callout_init(struct callout *, int); void _callout_init_lock(struct callout *, struct lock_object *, int); #define callout_init_mtx(c, mtx, flags) \ diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 2e784d6..67f37d8 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -452,6 +452,7 @@ typedef struct { #define SHT_MIPS_EH_REGION 0x70000027 #define SHT_MIPS_XLATE_OLD 0x70000028 #define SHT_MIPS_PDR_EXCEPTION 0x70000029 +#define SHT_MIPS_ABIFLAGS 0x7000002a #define SHT_SPARC_GOTDATA 0x70000000 diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 31659fa..bfcec98 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -155,6 +155,7 @@ OLD_FILES+=usr/share/man/man8/authpf-noip.8.gz OLD_FILES+=etc/autofs/include_ldap OLD_FILES+=etc/autofs/special_hosts OLD_FILES+=etc/autofs/special_media +OLD_FILES+=etc/autofs/special_noauto OLD_FILES+=etc/autofs/special_null OLD_FILES+=etc/auto_master OLD_FILES+=etc/rc.d/automount diff --git a/usr.bin/ctlstat/ctlstat.8 b/usr.bin/ctlstat/ctlstat.8 index 500ffb0..ebf9f5c 100644 --- a/usr.bin/ctlstat/ctlstat.8 +++ b/usr.bin/ctlstat/ctlstat.8 @@ -34,7 +34,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.bin/ctlstat/ctlstat.8#2 $ .\" $FreeBSD$ .\" -.Dd May 22, 2015 +.Dd September 21, 2015 .Dt CTLSTAT 8 .Os .Sh NAME @@ -50,6 +50,7 @@ .Op Fl j .Op Fl l Ar lun .Op Fl n Ar numdevs +.Op Fl p Ar port .Op Fl w Ar wait .Sh DESCRIPTION The @@ -64,7 +65,7 @@ The options are as follows: .Bl -tag -width 10n .It Fl t Total mode. -This displays separate columns with the total CTL read and write output, +This displays separate columns with the total read and write output, and a combined total column that also includes non I/O operations. .It Fl c Ar count Display statistics this many times. @@ -74,23 +75,20 @@ Disable CPU statistics display. Display DMA operation time (latency) instead of overall I/O time (latency). .It Fl D Text dump mode. -Dump all available statistics every 30 seconds in a text format suitable -for parsing. +Dump statistics every 30 seconds in a text format suitable for parsing. No statistics are computed in this mode, only raw numbers are displayed. .It Fl h Suppress display of the header. .It Fl j JSON dump mode. -Dump all available statistics every 30 seconds in JavaScript Object -Notation (JSON) format. +Dump statistics every 30 seconds in JavaScript Object Notation (JSON) format. No statistics are computed in this mode, only raw numbers are displayed. .It Fl l Ar lun Request statistics for the specified LUN. -This option is incompatible with total -.Fl ( t ) -mode. .It Fl n Ar numdevs Display statistics for this many devices. +.It Fl p Ar port +Request statistics for the specified port. .It Fl w Ar wait Wait this many seconds in between displays. If this option is not specified, diff --git a/usr.bin/ctlstat/ctlstat.c b/usr.bin/ctlstat/ctlstat.c index f12dd43..3587586 100644 --- a/usr.bin/ctlstat/ctlstat.c +++ b/usr.bin/ctlstat/ctlstat.c @@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$"); */ #define CTL_STAT_LUN_BITS 1024L -static const char *ctlstat_opts = "Cc:Ddhjl:n:tw:"; +static const char *ctlstat_opts = "Cc:Ddhjl:n:p:tw:"; static const char *ctlstat_usage = "Usage: ctlstat [-CDdjht] [-l lunnum]" "[-c count] [-n numdevs] [-w wait]\n"; @@ -102,12 +102,16 @@ typedef enum { #define CTLSTAT_FLAG_TOTALS (1 << 3) #define CTLSTAT_FLAG_DMA_TIME (1 << 4) #define CTLSTAT_FLAG_LUN_TIME_VALID (1 << 5) +#define CTLSTAT_FLAG_LUN_MASK (1 << 6) +#define CTLSTAT_FLAG_PORT_MASK (1 << 7) #define F_CPU(ctx) ((ctx)->flags & CTLSTAT_FLAG_CPU) #define F_HDR(ctx) ((ctx)->flags & CTLSTAT_FLAG_HEADER) #define F_FIRST(ctx) ((ctx)->flags & CTLSTAT_FLAG_FIRST_RUN) #define F_TOTALS(ctx) ((ctx)->flags & CTLSTAT_FLAG_TOTALS) #define F_DMA(ctx) ((ctx)->flags & CTLSTAT_FLAG_DMA_TIME) #define F_LUNVAL(ctx) ((ctx)->flags & CTLSTAT_FLAG_LUN_TIME_VALID) +#define F_LUNMASK(ctx) ((ctx)->flags & CTLSTAT_FLAG_LUN_MASK) +#define F_PORTMASK(ctx) ((ctx)->flags & CTLSTAT_FLAG_PORT_MASK) struct ctlstat_context { ctlstat_mode_types mode; @@ -120,6 +124,7 @@ struct ctlstat_context { uint64_t cur_total_jiffies, prev_total_jiffies; uint64_t cur_idle, prev_idle; bitstr_t bit_decl(lun_mask, CTL_STAT_LUN_BITS); + bitstr_t bit_decl(port_mask, CTL_MAX_PORTS); int num_luns; int numdevs; int header_interval; @@ -133,7 +138,8 @@ static void usage(int error); static int getstats(int fd, int *num_luns, struct ctl_lun_io_stats **xlun_stats, struct timespec *cur_time, int *lun_time_valid); static int getcpu(struct ctl_cpu_stats *cpu_stats); -static void compute_stats(struct ctl_lun_io_stats *cur_stats, +static void compute_stats(struct ctlstat_context *ctx, + struct ctl_lun_io_stats *cur_stats, struct ctl_lun_io_stats *prev_stats, long double etime, long double *mbsec, long double *kb_per_transfer, @@ -234,7 +240,7 @@ getcpu(struct ctl_cpu_stats *cpu_stats) } static void -compute_stats(struct ctl_lun_io_stats *cur_stats, +compute_stats(struct ctlstat_context *ctx, struct ctl_lun_io_stats *cur_stats, struct ctl_lun_io_stats *prev_stats, long double etime, long double *mbsec, long double *kb_per_transfer, long double *transfers_per_second, long double *ms_per_transfer, @@ -251,6 +257,9 @@ compute_stats(struct ctl_lun_io_stats *cur_stats, bzero(&total_time_ts, sizeof(total_time_ts)); bzero(&total_dma_ts, sizeof(total_dma_ts)); for (port = 0; port < CTL_MAX_PORTS; port++) { + if (F_PORTMASK(ctx) && + bit_test(ctx->port_mask, port) == 0) + continue; for (i = 0; i < CTL_STATS_NUM_TYPES; i++) { total_bytes += cur_stats->ports[port].bytes[i]; total_operations += @@ -326,8 +335,8 @@ compute_stats(struct ctl_lun_io_stats *cur_stats, */ #define PRINT_BINTIME(prefix, bt) \ - printf("%s %jd s %ju frac\n", prefix, (intmax_t)(bt).sec, \ - (uintmax_t)(bt).frac) + printf("%s %jd.%06ju\n", prefix, (intmax_t)(bt).sec, \ + (uintmax_t)(((bt).frac >> 32) * 1000000 >> 32)) static const char *iotypes[] = {"NO IO", "READ", "WRITE"}; static void @@ -336,8 +345,13 @@ ctlstat_dump(struct ctlstat_context *ctx) { struct ctl_lun_io_stats *stats = ctx->cur_lun_stats; for (lun = 0; lun < ctx->num_luns;lun++) { + if (F_LUNMASK(ctx) && bit_test(ctx->lun_mask, lun) == 0) + continue; printf("lun %d\n", lun); for (port = 0; port < CTL_MAX_PORTS; port++) { + if (F_PORTMASK(ctx) && + bit_test(ctx->port_mask, port) == 0) + continue; printf(" port %d\n", stats[lun].ports[port].targ_port); for (iotype = 0; iotype < CTL_STATS_NUM_TYPES; @@ -360,9 +374,8 @@ ctlstat_dump(struct ctlstat_context *ctx) { } #define JSON_BINTIME(prefix, bt) \ - printf("\"%s\":{\"sec\":%jd,\"frac\":%ju},", \ - prefix, (intmax_t)(bt).sec, (uintmax_t)(bt).frac) - + printf("\"%s\":%jd.%06ju,", prefix, (intmax_t)(bt).sec, \ + (uintmax_t)(((bt).frac >> 32) * 1000000 >> 32)) static void ctlstat_json(struct ctlstat_context *ctx) { int iotype, lun, port; @@ -370,8 +383,13 @@ ctlstat_json(struct ctlstat_context *ctx) { printf("{\"luns\":["); for (lun = 0; lun < ctx->num_luns; lun++) { + if (F_LUNMASK(ctx) && bit_test(ctx->lun_mask, lun) == 0) + continue; printf("{\"ports\":["); for (port = 0; port < CTL_MAX_PORTS;port++) { + if (F_PORTMASK(ctx) && + bit_test(ctx->port_mask, port) == 0) + continue; printf("{\"num\":%d,\"io\":[", stats[lun].ports[port].targ_port); for (iotype = 0; iotype < CTL_STATS_NUM_TYPES; @@ -442,17 +460,16 @@ ctlstat_standard(struct ctlstat_context *ctx) { hdr_devs = 0; + if (F_CPU(ctx)) + fprintf(stdout, " CPU"); if (F_TOTALS(ctx)) { - fprintf(stdout, "%s System Read %s" - "System Write %sSystem Total%s\n", - (F_LUNVAL(ctx) != 0) ? " " : "", - (F_LUNVAL(ctx) != 0) ? " " : "", - (F_LUNVAL(ctx) != 0) ? " " : "", - (F_CPU(ctx)) ? " CPU" : ""); + fprintf(stdout, "%s Read %s" + " Write %s Total\n", + (F_LUNVAL(ctx) != 0) ? " " : "", + (F_LUNVAL(ctx) != 0) ? " " : "", + (F_LUNVAL(ctx) != 0) ? " " : ""); hdr_devs = 3; } else { - if (F_CPU(ctx)) - fprintf(stdout, " CPU "); for (i = 0; i < min(CTL_STAT_LUN_BITS, ctx->num_luns); i++) { int lun; @@ -465,7 +482,8 @@ ctlstat_standard(struct ctlstat_context *ctx) { lun = (int)ctx->cur_lun_stats[i ].lun_number; - if (bit_test(ctx->lun_mask, lun) == 0) + if (F_LUNMASK(ctx) && + bit_test(ctx->lun_mask, lun) == 0) continue; fprintf(stdout, "%15.6s%d %s", "lun", lun, @@ -474,17 +492,19 @@ ctlstat_standard(struct ctlstat_context *ctx) { } fprintf(stdout, "\n"); } + if (F_CPU(ctx)) + fprintf(stdout, " "); for (i = 0; i < hdr_devs; i++) - fprintf(stdout, "%s %sKB/t %s MB/s ", - ((F_CPU(ctx) != 0) && (i == 0) && - (F_TOTALS(ctx) == 0)) ? " " : "", - (F_LUNVAL(ctx) != 0) ? " ms " : "", + fprintf(stdout, "%s KB/t %s MB/s", + (F_LUNVAL(ctx) != 0) ? " ms" : "", (F_DMA(ctx) == 0) ? "tps" : "dps"); fprintf(stdout, "\n"); ctx->header_interval = 20; } } + if (F_CPU(ctx)) + fprintf(stdout, "%3.0Lf%%", cpu_percentage); if (F_TOTALS(ctx) != 0) { long double mbsec[3]; long double kb_per_transfer[3]; @@ -516,7 +536,13 @@ ctlstat_standard(struct ctlstat_context *ctx) { &ctx->cur_lun_stats[i].ports[p].dma_time[j]) for (i = 0; i < ctx->num_luns; i++) { + if (F_LUNMASK(ctx) && bit_test(ctx->lun_mask, + (int)ctx->cur_lun_stats[i].lun_number) == 0) + continue; for (port = 0; port < CTL_MAX_PORTS; port++) { + if (F_PORTMASK(ctx) && + bit_test(ctx->port_mask, port) == 0) + continue; for (j = 0; j < CTL_STATS_NUM_TYPES; j++) { ADD_STATS_BYTES(2, port, i, j); ADD_STATS_OPERATIONS(2, port, i, j); @@ -541,29 +567,24 @@ ctlstat_standard(struct ctlstat_context *ctx) { } for (i = 0; i < 3; i++) { - compute_stats(&ctx->cur_total_stats[i], + compute_stats(ctx, &ctx->cur_total_stats[i], F_FIRST(ctx) ? NULL : &ctx->prev_total_stats[i], etime, &mbsec[i], &kb_per_transfer[i], &transfers_per_sec[i], &ms_per_transfer[i], &ms_per_dma[i], &dmas_per_sec[i]); if (F_DMA(ctx) != 0) - fprintf(stdout, " %2.2Lf", + fprintf(stdout, " %5.1Lf", ms_per_dma[i]); else if (F_LUNVAL(ctx) != 0) - fprintf(stdout, " %2.2Lf", + fprintf(stdout, " %5.1Lf", ms_per_transfer[i]); - fprintf(stdout, " %5.2Lf %3.0Lf %5.2Lf ", + fprintf(stdout, " %4.0Lf %5.0Lf %4.0Lf", kb_per_transfer[i], (F_DMA(ctx) == 0) ? transfers_per_sec[i] : dmas_per_sec[i], mbsec[i]); } - if (F_CPU(ctx)) - fprintf(stdout, " %5.1Lf%%", cpu_percentage); } else { - if (F_CPU(ctx)) - fprintf(stdout, "%5.1Lf%% ", cpu_percentage); - for (i = 0; i < min(CTL_STAT_LUN_BITS, ctx->num_luns); i++) { long double mbsec, kb_per_transfer; long double transfers_per_sec; @@ -571,21 +592,21 @@ ctlstat_standard(struct ctlstat_context *ctx) { long double ms_per_dma; long double dmas_per_sec; - if (bit_test(ctx->lun_mask, + if (F_LUNMASK(ctx) && bit_test(ctx->lun_mask, (int)ctx->cur_lun_stats[i].lun_number) == 0) continue; - compute_stats(&ctx->cur_lun_stats[i], F_FIRST(ctx) ? - NULL : &ctx->prev_lun_stats[i], etime, - &mbsec, &kb_per_transfer, - &transfers_per_sec, &ms_per_transfer, - &ms_per_dma, &dmas_per_sec); + compute_stats(ctx, &ctx->cur_lun_stats[i], + F_FIRST(ctx) ? NULL : &ctx->prev_lun_stats[i], + etime, &mbsec, &kb_per_transfer, + &transfers_per_sec, &ms_per_transfer, + &ms_per_dma, &dmas_per_sec); if (F_DMA(ctx)) - fprintf(stdout, " %2.2Lf", + fprintf(stdout, " %5.1Lf", ms_per_dma); else if (F_LUNVAL(ctx) != 0) - fprintf(stdout, " %2.2Lf", + fprintf(stdout, " %5.1Lf", ms_per_transfer); - fprintf(stdout, " %5.2Lf %3.0Lf %5.2Lf ", + fprintf(stdout, " %4.0Lf %5.0Lf %4.0Lf", kb_per_transfer, (F_DMA(ctx) == 0) ? transfers_per_sec : dmas_per_sec, mbsec); } @@ -597,7 +618,6 @@ main(int argc, char **argv) { int c; int count, waittime; - int set_lun; int fd, retval; struct ctlstat_context ctx; @@ -641,20 +661,30 @@ main(int argc, char **argv) if (cur_lun > CTL_STAT_LUN_BITS) errx(1, "Invalid LUN number %d", cur_lun); - bit_ffs(ctx.lun_mask, CTL_STAT_LUN_BITS, &set_lun); - if (set_lun == -1) + if (!F_LUNMASK(&ctx)) ctx.numdevs = 1; else ctx.numdevs++; bit_set(ctx.lun_mask, cur_lun); + ctx.flags |= CTLSTAT_FLAG_LUN_MASK; break; } case 'n': ctx.numdevs = atoi(optarg); break; + case 'p': { + int cur_port; + + cur_port = atoi(optarg); + if (cur_port > CTL_MAX_PORTS) + errx(1, "Invalid LUN number %d", cur_port); + + bit_set(ctx.port_mask, cur_port); + ctx.flags |= CTLSTAT_FLAG_PORT_MASK; + break; + } case 't': ctx.flags |= CTLSTAT_FLAG_TOTALS; - ctx.numdevs = 3; break; case 'w': waittime = atoi(optarg); @@ -667,13 +697,7 @@ main(int argc, char **argv) } } - bit_ffs(ctx.lun_mask, CTL_STAT_LUN_BITS, &set_lun); - - if ((F_TOTALS(&ctx)) - && (set_lun != -1)) { - errx(1, "Total Mode (-t) is incompatible with individual " - "LUN mode (-l)"); - } else if (set_lun == -1) { + if (!F_TOTALS(&ctx) && !F_LUNMASK(&ctx)) { /* * Note that this just selects the first N LUNs to display, * but at this point we have no knoweledge of which LUN @@ -682,6 +706,7 @@ main(int argc, char **argv) */ bit_nset(ctx.lun_mask, 0, min(ctx.numdevs - 1, CTL_STAT_LUN_BITS - 1)); + ctx.flags |= CTLSTAT_FLAG_LUN_MASK; } if ((fd = open(CTL_DEFAULT_DEV, O_RDWR)) == -1) diff --git a/usr.bin/elfdump/elfdump.c b/usr.bin/elfdump/elfdump.c index 2147fcb..33cc9c4 100644 --- a/usr.bin/elfdump/elfdump.c +++ b/usr.bin/elfdump/elfdump.c @@ -380,6 +380,7 @@ sh_types(uint64_t machine, uint64_t sht) { case EM_MIPS: switch (sht) { case SHT_MIPS_OPTIONS: return "SHT_MIPS_OPTIONS"; + case SHT_MIPS_ABIFLAGS: return "SHT_MIPS_ABIFLAGS"; } break; } diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c index 2ecc70f..6826e95 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.c @@ -119,6 +119,7 @@ struct cctl_lun { struct cctl_port { uint32_t port_id; + char *port_frontend; char *port_name; int pp; int vp; @@ -331,7 +332,10 @@ cctl_end_pelement(void *user_data, const char *name) devlist->cur_sb[devlist->level] = NULL; devlist->level--; - if (strcmp(name, "port_name") == 0) { + if (strcmp(name, "frontend_type") == 0) { + cur_port->port_frontend = str; + str = NULL; + } else if (strcmp(name, "port_name") == 0) { cur_port->port_name = str; str = NULL; } else if (strcmp(name, "physical_port") == 0) { @@ -506,6 +510,8 @@ retry_port: name = NULL; STAILQ_FOREACH(port, &devlist.port_list, links) { + if (strcmp(port->port_frontend, "ha") == 0) + continue; if (name) free(name); if (port->pp == 0 && port->vp == 0) diff --git a/usr.sbin/ngctl/dot.c b/usr.sbin/ngctl/dot.c index bd4673f..045101a 100644 --- a/usr.sbin/ngctl/dot.c +++ b/usr.sbin/ngctl/dot.c @@ -187,7 +187,7 @@ DotCmd(int ac, char **av) free(hlresp); } - fprintf(f, "};\n"); + fprintf(f, "}\n"); free(nlresp); if (f != stdout) |