├── .github └── workflows │ ├── package.yml │ └── validate.yml ├── .gitignore ├── MANIFEST.in ├── README.md ├── build-sdist.sh ├── build_judy.sh ├── include └── pointless │ ├── bitutils.h │ ├── custom_sort.h │ ├── pointless.h │ ├── pointless_bitvector.h │ ├── pointless_create.h │ ├── pointless_create_cache.h │ ├── pointless_cycle_marker.h │ ├── pointless_cycle_marker_wrappers.h │ ├── pointless_debug.h │ ├── pointless_defs.h │ ├── pointless_dynarray.h │ ├── pointless_eval.h │ ├── pointless_hash_table.h │ ├── pointless_int_ops.h │ ├── pointless_malloc.h │ ├── pointless_reader.h │ ├── pointless_reader_helpers.h │ ├── pointless_reader_utils.h │ ├── pointless_recreate.h │ ├── pointless_unicode_utils.h │ ├── pointless_validate.h │ ├── pointless_value.h │ └── pointless_walk.h ├── judy-1.0.5 ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── README ├── aclocal.m4 ├── autom4te.cache │ ├── output.0 │ ├── output.1 │ ├── requests │ ├── traces.0 │ └── traces.1 ├── bootstrap ├── compile ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── doc │ ├── Makefile.am │ ├── Makefile.in │ ├── ext │ │ ├── COPYRIGHT │ │ ├── Judy1_3.htm │ │ ├── Judy1_funcs_3.htm │ │ ├── JudyHS_3.htm │ │ ├── JudyHS_funcs_3.htm │ │ ├── JudyL_3.htm │ │ ├── JudyL_funcs_3.htm │ │ ├── JudySL_3.htm │ │ ├── JudySL_funcs_3.htm │ │ ├── Judy_3.htm │ │ ├── LICENSE │ │ ├── README │ │ └── README_deliver │ └── int │ │ └── 10minutes.htm ├── examples │ ├── Judy1Dup.c │ ├── Judy1Dup.h │ ├── Judy1DupCheck.c │ ├── Judy1Op.c │ ├── Judy1Op.h │ ├── Judy1OpCheck.c │ ├── Makefile │ └── README ├── install-sh ├── ltmain.sh ├── missing ├── src │ ├── Judy.h │ ├── Judy.h.check.c │ ├── Judy1 │ │ ├── Judy1.h │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── README │ ├── JudyCommon │ │ ├── JudyByCount.c │ │ ├── JudyCascade.c │ │ ├── JudyCount.c │ │ ├── JudyCreateBranch.c │ │ ├── JudyDecascade.c │ │ ├── JudyDel.c │ │ ├── JudyFirst.c │ │ ├── JudyFreeArray.c │ │ ├── JudyGet.c │ │ ├── JudyIns.c │ │ ├── JudyInsArray.c │ │ ├── JudyInsertBranch.c │ │ ├── JudyMalloc.c │ │ ├── JudyMallocIF.c │ │ ├── JudyMemActive.c │ │ ├── JudyMemUsed.c │ │ ├── JudyPrevNext.c │ │ ├── JudyPrevNextEmpty.c │ │ ├── JudyPrintJP.c │ │ ├── JudyPrivate.h │ │ ├── JudyPrivate1L.h │ │ ├── JudyPrivateBranch.h │ │ ├── JudyTables.c │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── README │ ├── JudyHS │ │ ├── JudyHS.c │ │ ├── JudyHS.h │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── README │ ├── JudyL │ │ ├── JudyL.h │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── README │ ├── JudySL │ │ ├── JudySL.c │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── README │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── apps │ │ ├── README │ │ └── demo │ │ │ ├── JudySort.c │ │ │ ├── Makefile_deliver │ │ │ ├── README │ │ │ ├── README_deliver │ │ │ ├── funhist.c │ │ │ ├── interL.c │ │ │ ├── interSL.c │ │ │ └── run_demo │ ├── build.bat │ ├── obj │ │ ├── Makefile.am │ │ └── Makefile.in │ └── sh_build ├── test │ ├── Centrino_1.3Mhz_Plots │ │ ├── Hash_CO.plot │ │ ├── JLHash_CO.plot │ │ ├── JudyHS_CO.plot │ │ └── JudySL_CO.plot │ ├── CheckDupLines.c │ ├── Checkit │ ├── Judy1LCheck.c │ ├── Judy1LHCheck.c │ ├── Judy1LHTime.c │ ├── Judy1LTime.c │ ├── JudyString.c │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── SLcompare.c │ ├── StringCompare.c │ ├── jbgraph │ ├── malloc-pre2.8a.c │ ├── simple.c │ ├── testjbgraph │ ├── timeit.c │ └── timeit.h └── tool │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── jhton.c │ └── listJPtype.c ├── pointless_ext.c ├── pointless_ext.h ├── pyproject.toml ├── python ├── pointless_bitvector.c ├── pointless_create.c ├── pointless_instance_dispatch.c ├── pointless_map.c ├── pointless_object.c ├── pointless_prim_vector.c ├── pointless_print.c ├── pointless_pyobject_cmp.c ├── pointless_pyobject_hash.c ├── pointless_set.c └── pointless_vector.c ├── sanity-check.py ├── setup.py ├── src ├── bitutils.c ├── custom_sort.c ├── pointless_bitvector.c ├── pointless_cmp.c ├── pointless_create.c ├── pointless_create_cache.c ├── pointless_cycle_marker.c ├── pointless_cycle_marker_wrappers.c ├── pointless_debug.c ├── pointless_dynarray.c ├── pointless_eval.c ├── pointless_hash.c ├── pointless_hash_table.c ├── pointless_int_ops.c ├── pointless_malloc.c ├── pointless_reader.c ├── pointless_reader_helpers.c ├── pointless_recreate.c ├── pointless_unicode_utils.c ├── pointless_validate.c ├── pointless_validate_hash_table.c ├── pointless_validate_heap.c ├── pointless_validate_heap_ref.c ├── pointless_value.c └── pointless_walk.c ├── test-requirements.txt ├── test.c └── tests ├── __init__.py ├── c_api ├── create.c ├── main.c ├── performance_test.c ├── test.h └── validate_hash.c ├── compile.sh ├── python_api ├── __init__.py ├── common.py ├── test_cmp.py ├── test_primvector.py ├── test_print.py ├── test_pypointless.py ├── test_serialize.py ├── test_set_map.py ├── test_thread_safe.py └── test_thread_safe_sort.py ├── run_recreate_test.sh ├── scc.py └── test_intop_eval.c /.github/workflows/package.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Python Packaging 4 | on: 5 | workflow_run: 6 | workflows: ['Validate'] 7 | types: 8 | - completed 9 | 10 | jobs: 11 | install: 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [macos-13, macos-14, ubuntu-24.04, ubuntu-24.04-arm] 16 | python-version: ['3.12'] 17 | 18 | steps: 19 | - name: Setup python 20 | uses: actions/setup-python@v5 21 | with: 22 | python-version: ${{ matrix.python-version }} 23 | 24 | - name: git checkout 25 | uses: actions/checkout@v4 26 | with: 27 | ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} 28 | submodules: true 29 | 30 | - name: Install cibuildwheel 31 | run: python -m pip install cibuildwheel==2.23.1 setuptools==77.0.3 32 | 33 | - name: Build wheels 34 | run: cibuildwheel --config-file pyproject.toml --output-dir wheelhouse 35 | 36 | - name: Build sdist 37 | if: ${{ matrix.os == 'ubuntu-24.04' }} 38 | run: ./build-sdist.sh 39 | 40 | - name: List wheels 41 | run: ls -l ./wheelhouse 42 | 43 | - name: Upload 44 | if: github.ref == 'refs/heads/master' 45 | env: 46 | TWINE_USERNAME: __token__ 47 | TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} 48 | run: | 49 | pip install twine 50 | twine upload --verbose --skip-existing wheelhouse/* 51 | -------------------------------------------------------------------------------- /.github/workflows/validate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Validate 4 | on: [ push, pull_request, workflow_dispatch ] 5 | 6 | jobs: 7 | validate: 8 | name: Syntax check all code in repository 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: [macos-13, macos-14, ubuntu-24.04, ubuntu-24.04-arm] 13 | python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} 19 | submodules: true 20 | 21 | - name: Set up Python ${{ matrix.python-version }} 22 | uses: actions/setup-python@v5 23 | with: 24 | python-version: ${{ matrix.python-version }} 25 | 26 | - name: Show Config 27 | run: | 28 | gcc --version 29 | 30 | - name: Test 31 | run: | 32 | python -m pip install -U pip 33 | pip install -r test-requirements.txt 34 | 35 | ./build_judy.sh 36 | (cd tests && ./compile.sh) 37 | pip install . 38 | 39 | (cd tests && ./a.out --unit-test) 40 | PYTHONPATH=$(pwd) python -m twisted.trial tests.python_api 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pyenv/ 2 | build/ 3 | dist/ 4 | judy-1.0.5/ 5 | pointless.egg-info/ 6 | venv-3.5.9/ 7 | venv-3.6.9/ 8 | venv-3.7.5/ 9 | venv-3.8.0/ 10 | wheelhouse/ 11 | *.map 12 | file.pointless 13 | __pycache__/ 14 | .mypy_cache/ 15 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include . *.h 2 | recursive-include ./judy-1.0.5 * 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | py-pointless 2 | ============ 3 | 4 | A fast and efficient read-only relocatable data structure for JSON like data, with C and Python APIs 5 | 6 | ```python 7 | import pointless 8 | 9 | pointless.serialize({1: 2, 3: 4}, 'file.pointless') 10 | 11 | root = pointless.Pointless('file.pointless').GetRoot() 12 | print(root, repr(root)) 13 | 14 | for k, v in root.items(): 15 | print(k, '->', v) 16 | ``` 17 | -------------------------------------------------------------------------------- /build-sdist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -xe 4 | 5 | mkdir -p ./wheelhouse 6 | 7 | python setup.py sdist --dist-dir ./wheelhouse 8 | 9 | # test it 10 | pip install -U pip virtualenv 11 | python -m virtualenv venv 12 | ./venv/bin/pip install ./wheelhouse/*.gz 13 | -------------------------------------------------------------------------------- /build_judy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bash --version 4 | 5 | set -xe 6 | 7 | basename="$(dirname "$0")" 8 | 9 | if [[ ${CC} ]]; then 10 | JUDYCC="$CC" 11 | else 12 | JUDYCC=gcc 13 | fi 14 | 15 | if [[ ! ${COPT} ]]; then 16 | COPT="-DJU_64BIT -O0 -fPIC -fno-strict-aliasing" 17 | fi 18 | 19 | 20 | if $JUDYCC -v 2>&1 >/dev/null | grep -E "clang|gcc version 4.6"; then 21 | COPT+="" 22 | else 23 | COPT+=" -fno-aggressive-loop-optimizations" 24 | fi 25 | 26 | (cd "$basename"; cd judy-1.0.5/src; CC="$JUDYCC" COPT="$COPT" sh ./sh_build) 27 | -------------------------------------------------------------------------------- /include/pointless/bitutils.h: -------------------------------------------------------------------------------- 1 | #ifndef __BITUTILS__H__ 2 | #define __BITUTILS__H__ 3 | 4 | #ifndef __cplusplus 5 | #include 6 | #include 7 | #else 8 | #include 9 | #include 10 | #endif 11 | 12 | void bm_set_(void* bitmask, uint64_t bit_index); 13 | void bm_reset_(void* bitmask, uint64_t bit_index); 14 | unsigned char bm_is_set_(void* bitmask, uint64_t bit_index); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/pointless/custom_sort.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS_CUSTOM__SORT__H__ 2 | #define __POINTLESS_CUSTOM__SORT__H__ 3 | 4 | #include 5 | 6 | #include 7 | 8 | typedef int (*qsort_cmp_)(int a, int b, int* c, void* user); 9 | typedef void (*qsort_swap_)(int a, int b, void* user); 10 | 11 | int bentley_sort_(int n, qsort_cmp_ cmp, qsort_swap_ swap, void* user); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/pointless/pointless.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__H__ 2 | #define __POINTLESS__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif 14 | 15 | 16 | -------------------------------------------------------------------------------- /include/pointless/pointless_bitvector.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__BITVECTOR__H__ 2 | #define __POINTLESS__BITVECTOR__H__ 3 | 4 | #include 5 | #include 6 | 7 | uint32_t pointless_bitvector_is_any_set(uint32_t t, pointless_value_data_t* v, void* bits); 8 | 9 | uint32_t pointless_bitvector_n_bits(uint32_t t, pointless_value_data_t* v, void* buffer); 10 | uint32_t pointless_bitvector_is_set(uint32_t t, pointless_value_data_t* v, void* buffer, uint32_t bit); 11 | 12 | uint32_t pointless_bitvector_hash_32(uint32_t t, pointless_value_data_t* v, void* buffer); 13 | uint64_t pointless_bitvector_hash_64(uint32_t t, pointless_value_data_t* v, void* buffer); 14 | 15 | int32_t pointless_bitvector_cmp_buffer_buffer(uint32_t t_a, pointless_value_data_t* v_a, void* buffer_a, uint32_t t_b, pointless_value_data_t* v_b, void* buffer_b); 16 | int32_t pointless_bitvector_cmp_bits_buffer(uint32_t n_bits_a, void* bits_a, pointless_value_t* v_b, void* buffer_b); 17 | int32_t pointless_bitvector_cmp_buffer_bits(pointless_value_t* v_a, void* buffer_a, uint32_t n_bits_b, void* bits_b); 18 | 19 | uint32_t pointless_bitvector_hash_buffer_32(void* buffer); 20 | uint64_t pointless_bitvector_hash_buffer_64(void* buffer); 21 | 22 | uint32_t pointless_bitvector_hash_n_bits_bits_32(uint32_t n_bits, void* bits); 23 | uint64_t pointless_bitvector_hash_n_bits_bits_64(uint32_t n_bits, void* bits); 24 | 25 | int32_t pointless_bitvector_cmp_buffer(void* a, void* b); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/pointless/pointless_create.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__CREATE__H__ 2 | #define __POINTLESS__CREATE__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef __cplusplus 9 | #include 10 | #include 11 | #else 12 | #include 13 | #include 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | // creation 28 | void pointless_create_begin_32(pointless_create_t* c); 29 | void pointless_create_begin_64(pointless_create_t* c); 30 | void pointless_create_end(pointless_create_t* c); 31 | int pointless_create_output_and_end_f(pointless_create_t* c, const char* fname, const char** error); 32 | int pointless_create_output_and_end_b(pointless_create_t* c, void** buf, size_t* buflen, const char** error); 33 | 34 | // set the root 35 | void pointless_create_set_root(pointless_create_t* c, uint32_t root); 36 | 37 | // inline-values 38 | uint32_t pointless_create_i32(pointless_create_t* c, int32_t v); 39 | uint32_t pointless_create_u32(pointless_create_t* c, uint32_t v); 40 | uint32_t pointless_create_float(pointless_create_t* c, float v); 41 | uint32_t pointless_create_null(pointless_create_t* c); 42 | 43 | uint32_t pointless_create_boolean_true(pointless_create_t* c); 44 | uint32_t pointless_create_boolean_false(pointless_create_t* c); 45 | uint32_t pointless_create_empty_slot(pointless_create_t* c); 46 | uint32_t pointless_create_boolean(pointless_create_t* c, int32_t v); 47 | 48 | // unicode constructors, using different sources 49 | uint32_t pointless_create_unicode_ucs4(pointless_create_t* c, uint32_t* s); 50 | uint32_t pointless_create_unicode_ucs2(pointless_create_t* c, uint16_t* s); 51 | uint32_t pointless_create_unicode_ascii(pointless_create_t* c, const char* s, const char** error); 52 | 53 | // string constructors, using different sources (each value must be at most 8 bits) 54 | uint32_t pointless_create_string_ucs4(pointless_create_t* c, uint32_t* v); 55 | uint32_t pointless_create_string_ucs2(pointless_create_t* c, uint16_t* s); 56 | uint32_t pointless_create_string_ascii(pointless_create_t* c, uint8_t* s); 57 | 58 | // bitvectors 59 | uint32_t pointless_create_bitvector(pointless_create_t* c, void* v, uint32_t n_bits); 60 | uint32_t pointless_create_bitvector_no_normalize(pointless_create_t* c, void* v, uint32_t n_bits); 61 | uint32_t pointless_create_bitvector_compressed(pointless_create_t* c, pointless_value_t* v); 62 | 63 | // vectors, buffer owned by library 64 | uint32_t pointless_create_vector_value(pointless_create_t* c); 65 | uint32_t pointless_create_vector_i8(pointless_create_t* c); 66 | uint32_t pointless_create_vector_u8(pointless_create_t* c); 67 | uint32_t pointless_create_vector_i16(pointless_create_t* c); 68 | uint32_t pointless_create_vector_u16(pointless_create_t* c); 69 | uint32_t pointless_create_vector_i32(pointless_create_t* c); 70 | uint32_t pointless_create_vector_u32(pointless_create_t* c); 71 | uint32_t pointless_create_vector_i64(pointless_create_t* c); 72 | uint32_t pointless_create_vector_u64(pointless_create_t* c); 73 | uint32_t pointless_create_vector_float(pointless_create_t* c); 74 | 75 | uint32_t pointless_create_vector_value_append(pointless_create_t* c, uint32_t vector, uint32_t v); 76 | uint32_t pointless_create_vector_i8_append(pointless_create_t* c, uint32_t vector, int8_t v); 77 | uint32_t pointless_create_vector_u8_append(pointless_create_t* c, uint32_t vector, uint8_t v); 78 | uint32_t pointless_create_vector_i16_append(pointless_create_t* c, uint32_t vector, int16_t v); 79 | uint32_t pointless_create_vector_u16_append(pointless_create_t* c, uint32_t vector, uint16_t v); 80 | uint32_t pointless_create_vector_i32_append(pointless_create_t* c, uint32_t vector, int32_t v); 81 | uint32_t pointless_create_vector_u32_append(pointless_create_t* c, uint32_t vector, uint32_t v); 82 | uint32_t pointless_create_vector_i64_append(pointless_create_t* c, uint32_t vector, int64_t v); 83 | uint32_t pointless_create_vector_u64_append(pointless_create_t* c, uint32_t vector, uint64_t v); 84 | uint32_t pointless_create_vector_float_append(pointless_create_t* c, uint32_t vector, float v); 85 | 86 | void pointless_create_vector_value_set(pointless_create_t* c, uint32_t vector, uint32_t i, uint32_t v); 87 | 88 | uint32_t pointless_create_vector_u32_transfer(pointless_create_t* c, uint32_t vector, uint32_t* v, uint32_t n); 89 | uint32_t pointless_create_vector_value_transfer(pointless_create_t* c, uint32_t vector, uint32_t* v, uint32_t n); 90 | 91 | // vectors, buffer owned by caller 92 | uint32_t pointless_create_vector_i8_owner(pointless_create_t* c, int8_t* items, uint32_t n_items); 93 | uint32_t pointless_create_vector_u8_owner(pointless_create_t* c, uint8_t* items, uint32_t n_items); 94 | uint32_t pointless_create_vector_i16_owner(pointless_create_t* c, int16_t* items, uint32_t n_items); 95 | uint32_t pointless_create_vector_u16_owner(pointless_create_t* c, uint16_t* items, uint32_t n_items); 96 | uint32_t pointless_create_vector_i32_owner(pointless_create_t* c, int32_t* items, uint32_t n_items); 97 | uint32_t pointless_create_vector_u32_owner(pointless_create_t* c, uint32_t* items, uint32_t n_items); 98 | uint32_t pointless_create_vector_i64_owner(pointless_create_t* c, int64_t* items, uint32_t n_items); 99 | uint32_t pointless_create_vector_u64_owner(pointless_create_t* c, uint64_t* items, uint32_t n_items); 100 | uint32_t pointless_create_vector_float_owner(pointless_create_t* c, float* items, uint32_t n_items); 101 | 102 | // sets 103 | uint32_t pointless_create_set(pointless_create_t* c); 104 | uint32_t pointless_create_set_add(pointless_create_t* c, uint32_t s, uint32_t k); 105 | 106 | // maps 107 | uint32_t pointless_create_map(pointless_create_t* c); 108 | uint32_t pointless_create_map_add(pointless_create_t* c, uint32_t m, uint32_t k, uint32_t v); 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /include/pointless/pointless_create_cache.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__CREATE__CACHE__H__ 2 | #define __POINTLESS__CREATE__CACHE__H__ 3 | 4 | #ifndef __cplusplus 5 | #include 6 | #include 7 | #else 8 | #include 9 | #include 10 | #endif 11 | 12 | #define POINTLESS_CREATE_CACHE_N_U32 (10000) 13 | 14 | #define POINTLESS_CREATE_CACHE_MIN_I32 (-10000) 15 | #define POINTLESS_CREATE_CACHE_MAX_I32 (10000) 16 | 17 | typedef struct { 18 | uint32_t init; 19 | uint32_t u32_cache[POINTLESS_CREATE_CACHE_N_U32]; 20 | uint32_t i32_cache[POINTLESS_CREATE_CACHE_MAX_I32 - POINTLESS_CREATE_CACHE_MIN_I32 + 1]; 21 | uint32_t null_handle; 22 | uint32_t empty_slot_handle; 23 | uint32_t true_handle; 24 | uint32_t false_handle; 25 | } pointless_create_cache_t; 26 | 27 | 28 | // initialize cache 29 | void pointless_create_cache_init(pointless_create_cache_t* cache, uint32_t init_value); 30 | 31 | // U32 32 | uint32_t pointless_create_cache_get_u32(pointless_create_cache_t* cache, uint32_t u32); 33 | void pointless_create_cache_set_u32(pointless_create_cache_t* cache, uint32_t u32, uint32_t handle); 34 | 35 | // I32 36 | uint32_t pointless_create_cache_get_i32(pointless_create_cache_t* cache, int32_t i32); 37 | void pointless_create_cache_set_i32(pointless_create_cache_t* cache, int32_t i32, uint32_t handle); 38 | 39 | // NULL 40 | uint32_t pointless_create_cache_get_null(pointless_create_cache_t* cache); 41 | void pointless_create_cache_set_null(pointless_create_cache_t* cache, uint32_t handle); 42 | 43 | // EMPTY_SLOT 44 | uint32_t pointless_create_cache_get_empty_slot(pointless_create_cache_t* cache); 45 | void pointless_create_cache_set_empty_slot(pointless_create_cache_t* cache, uint32_t handle); 46 | 47 | // TRUE 48 | uint32_t pointless_create_cache_get_true(pointless_create_cache_t* cache); 49 | void pointless_create_cache_set_true(pointless_create_cache_t* cache, uint32_t handle); 50 | 51 | // FALSE 52 | uint32_t pointless_create_cache_get_false(pointless_create_cache_t* cache); 53 | void pointless_create_cache_set_false(pointless_create_cache_t* cache, uint32_t handle); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/pointless/pointless_cycle_marker.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__CYCLE__MARKER__H__ 2 | #define __POINTLESS__CYCLE__MARKER__H__ 3 | 4 | #include 5 | #include 6 | 7 | typedef uint32_t (*pointless_cycle_n_nodes)(void* user); 8 | typedef uint64_t (*pointless_cycle_get_root)(void* user); 9 | typedef int (*pointless_cycle_is_container)(void* user, uint64_t node); 10 | typedef uint32_t (*pointless_cycle_container_id)(void* user, uint64_t node); 11 | typedef uint32_t (*pointless_cycle_n_children)(void* user, uint64_t node); 12 | typedef uint64_t (*pointless_cycle_child_at)(void* user, uint64_t node, uint32_t i); 13 | 14 | typedef struct { 15 | void* user; 16 | pointless_cycle_n_nodes fn_n_nodes; 17 | pointless_cycle_get_root fn_get_root; 18 | pointless_cycle_is_container fn_is_container; 19 | pointless_cycle_container_id fn_container_id; 20 | pointless_cycle_n_children fn_n_children; 21 | pointless_cycle_child_at fn_child_at; 22 | } cycle_marker_info_t; 23 | 24 | // returned buffer needs to be free()'d 25 | void* pointless_cycle_marker(cycle_marker_info_t* info, const char** error); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/pointless/pointless_cycle_marker_wrappers.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__CYCLE__MARKER__WRAPPERS__H__ 2 | #define __POINTLESS__CYCLE__MARKER__WRAPPERS__H__ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | // returned buffer needs to be free()'d 10 | void* pointless_cycle_marker_read(pointless_t* p, const char** error); 11 | void* pointless_cycle_marker_create(pointless_create_t* c, const char** error); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/pointless/pointless_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__DEBUG__H__ 2 | #define __POINTLESS__DEBUG__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef __cplusplus 9 | #include 10 | #include 11 | #else 12 | #include 13 | #include 14 | #endif 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | int pointless_debug_print(pointless_t* p, FILE* out, const char** error); 24 | int pointless_debug_print_value(pointless_t* p, pointless_value_t* v, FILE* out, const char** error); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/pointless/pointless_dynarray.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__DYNARRAY__H__ 2 | #define __POINTLESS__DYNARRAY__H__ 3 | 4 | #include 5 | #include 6 | 7 | #ifndef __cplusplus 8 | #include 9 | #include 10 | #else 11 | #include 12 | #include 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | typedef struct { 19 | void* _data; 20 | size_t n_items; 21 | size_t n_alloc; 22 | size_t item_size; 23 | } pointless_dynarray_t; 24 | 25 | #define pointless_dynarray_ITEM_AT(T, A, I) ((T*)(A)->_data)[I] 26 | 27 | void pointless_dynarray_init(pointless_dynarray_t* a, size_t item_size); 28 | size_t pointless_dynarray_n_items(pointless_dynarray_t* a); 29 | size_t pointless_dynarray_n_heap_bytes(pointless_dynarray_t* a); 30 | void pointless_dynarray_pop(pointless_dynarray_t* a); 31 | int pointless_dynarray_push(pointless_dynarray_t* a, void* i); 32 | int pointless_dynarray_push_bulk(pointless_dynarray_t* a, void* i, size_t n_items); 33 | void pointless_dynarray_clear(pointless_dynarray_t* a); 34 | void pointless_dynarray_destroy(pointless_dynarray_t* a); 35 | void* pointless_dynarray_item_at(pointless_dynarray_t* a, size_t i); 36 | void* pointless_dynarray_buffer(pointless_dynarray_t* a); 37 | void pointless_dynarray_swap(pointless_dynarray_t* a, size_t i, size_t j); 38 | void pointless_dynarray_give_data(pointless_dynarray_t* a, void* data, size_t n_items); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/pointless/pointless_eval.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__EVAL__H__ 2 | #define __POINTLESS__EVAL__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifndef __cplusplus 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | // a simple utility to evaluate simple expressions on arbitrary pointless-values 22 | // 23 | // it supports map/vector/bitvector values, indexed using integers or strings 24 | // 25 | // example: ["some_key_in_map"][10][10] 26 | // 27 | // it can also fill in values, printf-style supporting these format specifiers: 28 | // %s: const char* 29 | // %u32: uint32_t 30 | // %i32: int32_t 31 | // %u64: uint64_t 32 | // %i64: int64_t 33 | int pointless_eval_get(pointless_t* p, pointless_value_t* root, pointless_value_t* v, const char* e, ...); 34 | 35 | // and convencience functions 36 | int pointless_eval_get_as_u32(pointless_t* p, pointless_value_t* root, uint32_t* v, const char* e, ...); 37 | int pointless_eval_get_as_map(pointless_t* p, pointless_value_t* root, pointless_value_t* v, const char* e, ...); 38 | int pointless_eval_get_as_string(pointless_t* p, pointless_value_t* root, uint8_t** v, const char* e, ...); 39 | int pointless_eval_get_as_vector_u8(pointless_t* p, pointless_value_t* root, uint8_t** v, uint32_t* n, const char* e, ...); 40 | int pointless_eval_get_as_vector_u16(pointless_t* p, pointless_value_t* root, uint16_t** v, uint32_t* n, const char* e, ...); 41 | int pointless_eval_get_as_vector_u32(pointless_t* p, pointless_value_t* root, uint32_t** v, uint32_t* n, const char* e, ...); 42 | int pointless_eval_get_as_vector_u64(pointless_t* p, pointless_value_t* root, uint64_t** v, uint32_t* n, const char* e, ...); 43 | int pointless_eval_get_as_vector_f(pointless_t* p, pointless_value_t* root, float** v, uint32_t* n, const char* e, ...); 44 | int pointless_eval_get_as_vector_value(pointless_t* p, pointless_value_t* root, pointless_value_t** v, uint32_t* n, const char* e, ...); 45 | int pointless_eval_get_as_bitvector(pointless_t* p, pointless_value_t* root, pointless_value_t* v, uint32_t* n, const char* e, ...); 46 | int pointless_eval_get_as_boolean(pointless_t* p, pointless_value_t* root, uint32_t* v, const char* e, ...); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/pointless/pointless_hash_table.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__HASH__TABLE__H__ 2 | #define __POINTLESS__HASH__TABLE__H__ 3 | 4 | #ifndef __cplusplus 5 | #include 6 | #include 7 | #else 8 | #include 9 | #include 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #define POINTLESS_HASH_TABLE_PROBE_MISS UINT32_MAX 16 | #define POINTLESS_HASH_TABLE_PROBE_ERROR (UINT32_MAX-1) 17 | 18 | typedef struct { 19 | uint32_t perturb; 20 | uint32_t i; 21 | uint32_t mask; 22 | } pointless_hash_iter_state_t; 23 | 24 | uint32_t pointless_hash_compute_n_buckets(uint32_t n_items); 25 | uint32_t pointless_hash_table_probe(pointless_t* p, uint32_t value_hash, pointless_value_t* value, uint32_t n_buckets, uint32_t* hash_vector, pointless_value_t* key_vector, const char** error); 26 | uint32_t pointless_hash_table_probe_ext(pointless_t* p, uint32_t value_hash, pointless_eq_cb cb, void* user, uint32_t n_buckets, uint32_t* hash_vector, pointless_value_t* key_vector, const char** error); 27 | int pointless_hash_table_populate(pointless_create_t* c, uint32_t* hash_vector, uint32_t* keys_vector, uint32_t* values_vector, uint32_t n_keys, uint32_t* hash_serialize, uint32_t* keys_serialize, uint32_t* values_serialize, uint32_t n_buckets, uint32_t empty_slot_handle, const char** error); 28 | 29 | void pointless_hash_table_probe_hash_init(pointless_t* p, uint32_t value_hash, uint32_t n_buckets, pointless_hash_iter_state_t* state); 30 | uint32_t pointless_hash_table_probe_hash(pointless_t* p, uint32_t* hash_vector, pointless_value_t* key_vector, pointless_hash_iter_state_t* state, uint32_t* bucket_out); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/pointless/pointless_int_ops.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__INT__OPS__H__ 2 | #define __POINTLESS__INT__OPS__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifndef __cplusplus 10 | #include 11 | #include 12 | #else 13 | #include 14 | #include 15 | #endif 16 | 17 | // values 18 | typedef struct { 19 | int is_overflow; 20 | size_t value; 21 | } intop_sizet_t; 22 | 23 | typedef struct { 24 | int is_overflow; 25 | uint32_t value; 26 | } intop_u32_t; 27 | 28 | typedef struct { 29 | int is_overflow; 30 | uint64_t value; 31 | } intop_u64_t; 32 | 33 | // multiply 34 | intop_sizet_t intop_sizet_mult(intop_sizet_t a, intop_sizet_t b); 35 | intop_u64_t intop_u64_mult(intop_u64_t a, intop_u64_t b); 36 | intop_u32_t intop_u32_mult(intop_u32_t, intop_u32_t b); 37 | 38 | // add 39 | intop_sizet_t intop_sizet_add(intop_sizet_t a, intop_sizet_t b); 40 | intop_u32_t intop_u32_add(intop_u32_t a, intop_u32_t b); 41 | intop_u64_t intop_u64_add(intop_u64_t a, intop_u64_t b); 42 | 43 | // value constructors 44 | intop_sizet_t intop_sizet_init(size_t v); 45 | intop_u32_t intop_u32_init(uint32_t v); 46 | intop_u64_t intop_u64_init(uint64_t v); 47 | 48 | // expression evalator, roughly the grammar: 49 | // E = T+T, T = E*E, F = (E)|number|x 50 | // x is a standin for a positional variable 51 | 52 | #define INTOP_EVAL_NUMBER 0 53 | #define INTOP_EVAL_ADD 1 54 | #define INTOP_EVAL_SUB 2 55 | #define INTOP_EVAL_MUL 3 56 | #define INTOP_EVAL_DIV 4 57 | #define INTOP_EVAL_LPAREN 5 58 | #define INTOP_EVAL_RPAREN 6 59 | #define INTOP_EVAL_VARIABLE 7 60 | 61 | typedef struct { 62 | int type; 63 | intop_u64_t number; 64 | int var_index; 65 | } intop_eval_token_t; 66 | 67 | #define INTOP_EVAL_MAX_N 512 68 | 69 | typedef struct { 70 | // token list, and current token 71 | int i; 72 | int n; 73 | intop_eval_token_t tokens[INTOP_EVAL_MAX_N]; 74 | 75 | // compile stack 76 | intop_eval_token_t stack[INTOP_EVAL_MAX_N]; 77 | int s_n; 78 | 79 | // eval stack 80 | intop_eval_token_t eval[INTOP_EVAL_MAX_N]; 81 | int e_n; 82 | 83 | // error 84 | const char* s_error; 85 | int i_error; 86 | } intop_eval_context_t; 87 | 88 | int intop_eval_compile(const char* s, intop_eval_context_t* context, const char** error); 89 | int intop_eval_eval(intop_eval_context_t* context, uint64_t* r, const char** error, ...); 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /include/pointless/pointless_malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS_MALLOC__H__ 2 | #define __POINTLESS_MALLOC__H__ 3 | 4 | #include 5 | #include 6 | 7 | void* pointless_calloc(size_t nmemb, size_t size); 8 | void* pointless_malloc(size_t size); 9 | void pointless_free(void* ptr); 10 | void* pointless_realloc(void* ptr, size_t size); 11 | char* pointless_strdup(const char* s); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/pointless/pointless_reader.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__READER__H__ 2 | #define __POINTLESS__READER__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef __cplusplus 9 | #include 10 | #include 11 | #else 12 | #include 13 | #include 14 | #endif 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | int pointless_open_f(pointless_t* p, const char* fname, const char** error); 29 | int pointless_open_b(pointless_t* p, const void* buffer, size_t n_buffer, const char** error); 30 | 31 | // use these two with care. they don't perform any validation on the underlying data, which may cause 32 | // segfaults when accessed through the normal pointless-library functions 33 | int pointless_open_f_skip_validate(pointless_t* p, const char* fname, const char** error); 34 | int pointless_open_b_skip_validate(pointless_t* p, const void* buffer, size_t n_buffer, const char** error); 35 | 36 | void pointless_close(pointless_t* p); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/pointless/pointless_reader_helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__READER__HELPERS__H__ 2 | #define __POINTLESS__READER__HELPERS__H__ 3 | 4 | #include 5 | #include 6 | 7 | // map operator wrappers 8 | int pointless_get_mapping_string_to_u32(pointless_t* p, pointless_value_t* map, char* key, uint32_t* value); 9 | int pointless_get_mapping_string_to_i64(pointless_t* p, pointless_value_t* map, char* key, int64_t* value); 10 | int pointless_get_mapping_string_to_set(pointless_t* p, pointless_value_t* map, char* key, pointless_value_t* s); 11 | int pointless_get_mapping_string_to_map(pointless_t* p, pointless_value_t* map, char* key, pointless_value_t* m); 12 | int pointless_get_mapping_string_to_value(pointless_t* p, pointless_value_t* map, char* key, pointless_value_t* m); 13 | int pointless_get_mapping_int_to_value(pointless_t* p, pointless_value_t* map, int64_t i, pointless_value_t* v); 14 | int pointless_get_mapping_string_to_value(pointless_t* p, pointless_value_t* map, char* key, pointless_value_t* value); 15 | int pointless_get_mapping_string_n_to_value(pointless_t* p, pointless_value_t* map, char* key, size_t n, pointless_value_t* value); 16 | 17 | int pointless_get_mapping_unicode_to_value(pointless_t* p, pointless_value_t* map, uint32_t* key, pointless_value_t* value); 18 | int pointless_get_mapping_unicode_to_u32(pointless_t* p, pointless_value_t* map, uint32_t* key, uint32_t* value); 19 | 20 | int pointless_get_mapping_string_to_vector(pointless_t* p, pointless_value_t* map, char* key, pointless_value_t* v, uint32_t* n_items); 21 | int pointless_get_mapping_string_to_vector_i8(pointless_t* p, pointless_value_t* map, char* key, int8_t** value, uint32_t* n_items); 22 | int pointless_get_mapping_string_to_vector_u8(pointless_t* p, pointless_value_t* map, char* key, uint8_t** value, uint32_t* n_items); 23 | int pointless_get_mapping_string_to_vector_i16(pointless_t* p, pointless_value_t* map, char* key, int16_t** value, uint32_t* n_items); 24 | int pointless_get_mapping_string_to_vector_u16(pointless_t* p, pointless_value_t* map, char* key, uint16_t** value, uint32_t* n_items); 25 | int pointless_get_mapping_string_to_vector_i32(pointless_t* p, pointless_value_t* map, char* key, int32_t** value, uint32_t* n_items); 26 | int pointless_get_mapping_string_to_vector_u32(pointless_t* p, pointless_value_t* map, char* key, uint32_t** value, uint32_t* n_items); 27 | int pointless_get_mapping_string_to_vector_i64(pointless_t* p, pointless_value_t* map, char* key, int64_t** value, uint32_t* n_items); 28 | int pointless_get_mapping_string_to_vector_u64(pointless_t* p, pointless_value_t* map, char* key, uint64_t** value, uint32_t* n_items); 29 | 30 | int pointless_get_mapping_string_to_vector_float(pointless_t* p, pointless_value_t* map, char* key, float** value, uint32_t* n_items); 31 | int pointless_get_mapping_string_to_vector_value(pointless_t* p, pointless_value_t* map, char* key, pointless_value_t** value, uint32_t* n_items); 32 | 33 | // set/map inclusion wrappers 34 | int pointless_is_int_in_set(pointless_t* p, pointless_value_t* s, int64_t i); 35 | int pointless_is_int_in_map(pointless_t* p, pointless_value_t* m, int64_t i); 36 | 37 | // test for set of keys equivalence 38 | int pointless_has_same_keys_set_map(pointless_t* p, pointless_value_t* s, pointless_value_t* m); 39 | int pointless_has_same_keys_map_map(pointless_t* p, pointless_value_t* m_a, pointless_value_t* m_b); 40 | 41 | // test for key inclusion, for values which are guaranteed to be acyclic (all containers and values, except non-hashable value-vectors or those containing one) 42 | int pointless_is_in_set_acyclic(pointless_t* p, pointless_value_t* s, pointless_value_t* k); 43 | int pointless_is_in_map_acyclic(pointless_t* p, pointless_value_t* m, pointless_value_t* k); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/pointless/pointless_reader_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__READER__UTILS__H__ 2 | #define __POINTLESS__READER__UTILS__H__ 3 | 4 | #include 5 | #include 6 | 7 | // the root value 8 | pointless_value_t* pointless_root(pointless_t* p); 9 | 10 | // string/unicode values, and encoders 11 | uint32_t pointless_reader_unicode_len(pointless_t* p, pointless_value_t* v); 12 | uint32_t* pointless_reader_unicode_value_ucs4(pointless_t* p, pointless_value_t* v); 13 | 14 | uint32_t pointless_reader_string_len(pointless_t* p, pointless_value_t* v); 15 | uint8_t* pointless_reader_string_value_ascii(pointless_t* p, pointless_value_t* v); 16 | 17 | // vectors 18 | uint32_t pointless_reader_vector_n_items(pointless_t* p, pointless_value_t* v); 19 | pointless_value_t* pointless_reader_vector_value(pointless_t* p, pointless_value_t* v); 20 | pointless_complete_value_t pointless_reader_complete_vector_value(pointless_t* p, pointless_value_t* v); 21 | int8_t* pointless_reader_vector_i8(pointless_t* p, pointless_value_t* v); 22 | uint8_t* pointless_reader_vector_u8(pointless_t* p, pointless_value_t* v); 23 | int16_t* pointless_reader_vector_i16(pointless_t* p, pointless_value_t* v); 24 | uint16_t* pointless_reader_vector_u16(pointless_t* p, pointless_value_t* v); 25 | int32_t* pointless_reader_vector_i32(pointless_t* p, pointless_value_t* v); 26 | uint32_t* pointless_reader_vector_u32(pointless_t* p, pointless_value_t* v); 27 | int64_t* pointless_reader_vector_i64(pointless_t* p, pointless_value_t* v); 28 | uint64_t* pointless_reader_vector_u64(pointless_t* p, pointless_value_t* v); 29 | float* pointless_reader_vector_float(pointless_t* p, pointless_value_t* v); 30 | 31 | // general value fetcher 32 | pointless_complete_value_t pointless_reader_vector_value_case(pointless_t* p, pointless_value_t* v, uint32_t i); 33 | 34 | // bitvectors 35 | uint32_t pointless_reader_bitvector_n_bits(pointless_t* p, pointless_value_t* v); 36 | uint32_t pointless_reader_bitvector_is_set(pointless_t* p, pointless_value_t* v, uint32_t bit); 37 | void* pointless_reader_bitvector_buffer(pointless_t* p, pointless_value_t* v); 38 | 39 | // sets 40 | uint32_t pointless_reader_set_n_items(pointless_t* p, pointless_value_t* s); 41 | uint32_t pointless_reader_set_n_buckets(pointless_t* p, pointless_value_t* s); 42 | uint32_t pointless_reader_set_iter(pointless_t* p, pointless_value_t* s, pointless_value_t** k, uint32_t* iter_state); 43 | void pointless_reader_set_lookup(pointless_t* p, pointless_value_t* s, pointless_value_t* k, pointless_value_t** kk, const char** error); 44 | void pointless_reader_set_lookup_ext(pointless_t* p, pointless_value_t* s, uint32_t hash, pointless_eq_cb cb, void* user, pointless_value_t** kk, const char** error); 45 | 46 | pointless_value_t* pointless_set_hash_vector(pointless_t* p, pointless_value_t* s); 47 | pointless_value_t* pointless_set_key_vector(pointless_t* p, pointless_value_t* s); 48 | 49 | // maps 50 | uint32_t pointless_reader_map_n_items(pointless_t* p, pointless_value_t* m); 51 | uint32_t pointless_reader_map_n_buckets(pointless_t* p, pointless_value_t* m); 52 | uint32_t pointless_reader_map_iter(pointless_t* p, pointless_value_t* m, pointless_value_t** k, pointless_value_t** vv, uint32_t* iter_state); 53 | void pointless_reader_map_lookup(pointless_t* p, pointless_value_t* m, pointless_value_t* k, pointless_value_t** kk, pointless_value_t** vv, const char** error); 54 | void pointless_reader_map_lookup_ext(pointless_t* p, pointless_value_t* m, uint32_t hash, pointless_eq_cb cb, void* user, pointless_value_t** kk, pointless_value_t** vv, const char** error); 55 | 56 | pointless_value_t* pointless_map_hash_vector(pointless_t* p, pointless_value_t* m); 57 | pointless_value_t* pointless_map_key_vector(pointless_t* p, pointless_value_t* m); 58 | pointless_value_t* pointless_map_value_vector(pointless_t* p, pointless_value_t* m); 59 | 60 | // map/set conditional iterators 61 | void pointless_reader_map_iter_hash_init(pointless_t* p, pointless_value_t* m, uint32_t hash, pointless_hash_iter_state_t* iter_state); 62 | uint32_t pointless_reader_map_iter_hash(pointless_t* p, pointless_value_t* m, uint32_t hash, pointless_value_t** kk, pointless_value_t** vv, pointless_hash_iter_state_t* iter_state); 63 | 64 | void pointless_reader_set_iter_hash_init(pointless_t* p, pointless_value_t* m, uint32_t hash, pointless_hash_iter_state_t* iter_state); 65 | uint32_t pointless_reader_set_iter_hash(pointless_t* p, pointless_value_t* s, uint32_t hash, pointless_value_t** kk, pointless_hash_iter_state_t* iter_state); 66 | 67 | // get ID of container (non-empty vectors, sets and maps) 68 | uint32_t pointless_n_containers(pointless_t* p); 69 | uint32_t pointless_container_id(pointless_t* p, pointless_value_t* c); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /include/pointless/pointless_recreate.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__RECREATE__H__ 2 | #define __POINTLESS__RECREATE__H__ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | uint32_t pointless_recreate_value(pointless_t* p_in, pointless_value_t* v_in, pointless_create_t* c_out, const char** error); 10 | 11 | int pointless_recreate_64(const char* fname_in, const char* fname_out, const char** error); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/pointless/pointless_unicode_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__UNICODE__UTILS__H__ 2 | #define __POINTLESS__UNICODE__UTILS__H__ 3 | 4 | #ifndef __cplusplus 5 | #include 6 | #include 7 | #else 8 | #include 9 | #include 10 | #endif 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | // range check 18 | int pointless_is_ucs4_ascii(uint32_t* s); 19 | int pointless_is_ucs4_ucs2(uint32_t* s); 20 | int pointless_is_ucs2_ascii(uint16_t* s); 21 | 22 | // length check 23 | size_t pointless_ucs4_len(uint32_t* s); 24 | size_t pointless_ucs2_len(uint16_t* s); 25 | size_t pointless_ascii_len(uint8_t* s); 26 | size_t pointless_ucs1_len(uint8_t* s); 27 | 28 | // strcpy() 29 | void pointless_ucs4_cpy(uint32_t* dst, const uint32_t* src); 30 | void pointless_ucs2_cpy(uint16_t* dst, const uint16_t* src); 31 | void pointless_ascii_cpy(uint8_t* dst, const uint8_t* src); 32 | 33 | // converters, caller must pointless_free() buffers 34 | 35 | // ucs-4 36 | uint16_t* pointless_ucs4_to_ucs2(uint32_t* ucs4); 37 | uint8_t* pointless_ucs4_to_ascii(uint32_t* ucs4); 38 | 39 | // ucs-2 40 | uint32_t* pointless_ucs2_to_ucs4(uint16_t* ucs2); 41 | uint8_t* pointless_ucs2_to_ascii(uint16_t* ucs2); 42 | 43 | // ascii 44 | uint32_t* pointless_ascii_to_ucs4(uint8_t* ascii); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/pointless/pointless_validate.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__VALIDATE__H__ 2 | #define __POINTLESS__VALIDATE__H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | /* 12 | We have to perform exhaustive validation when opening a pointless file, since 13 | invalid files may crash the pointless API even when used correctly. Our 14 | guarantee is that correct use of the API will never produce invalid results or 15 | errors. 16 | 17 | There are a few basic checks we do, and two structural checks. First the simple 18 | ones: 19 | 20 | a) there must be a header 21 | b) there must be offset vectors matching the number of types given in the header 22 | 23 | Then, all values reachable from the root must have a place in the corresponding 24 | heaps, or if they are inline-values, they must be valid. 25 | 26 | Then there are more complicated checks which check the following: 27 | 28 | a) the recursive depth does not exceed POINTLESS_MAX_DEPTH 29 | b) all keys in sets/maps are hashable 30 | c) all sets/maps are setup correctly w.r.t. probing strategy 31 | d) all hashable vectors are not part of a cycle 32 | 33 | Each hashable data type is either a non-compressed vector, or unicodes or inline 34 | values. The only data type which is not allowed in a cycle is hashable vectors. 35 | 36 | Each hashable value can only recurse down to hashable values. 37 | 38 | Checking all this is pretty expensive, and is done after the first set of tests. 39 | */ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | typedef struct { 49 | pointless_t* p; 50 | } pointless_validate_context_t; 51 | 52 | int32_t pointless_validate(pointless_validate_context_t* context, const char** error); 53 | 54 | // checks if the offset vector reference is good, and that the heap data is valid, without 55 | // checking the children (if any) 56 | int32_t pointless_validate_heap_ref(pointless_validate_context_t* context, pointless_value_t* v, const char** error); 57 | 58 | // checks if the internal invariants of an inline-value hold 59 | int32_t pointless_validate_inline_invariants(pointless_validate_context_t* context, pointless_value_t* v, const char** error); 60 | 61 | // check heap data 62 | int32_t pointless_validate_heap_value(pointless_validate_context_t* context, pointless_value_t* v, const char** error); 63 | 64 | // validate hash table invariants 65 | int32_t pointless_hash_table_validate(pointless_t* p, uint32_t n_items, uint32_t n_buckets, uint32_t* hash_vector, pointless_value_t* key_vector, pointless_value_t* value_vector, const char** error); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /include/pointless/pointless_value.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__TYPE__H__ 2 | #define __POINTLESS__TYPE__H__ 3 | 4 | #include 5 | #include 6 | 7 | #ifndef __cplusplus 8 | #include 9 | #include 10 | #else 11 | #include 12 | #include 13 | #endif 14 | 15 | #include 16 | 17 | // create-time values 18 | pointless_create_value_t pointless_value_create_i32(int32_t v); 19 | pointless_create_value_t pointless_value_create_u32(uint32_t v); 20 | pointless_create_value_t pointless_value_create_float(float v); 21 | 22 | pointless_create_value_t pointless_value_create_bool_false(); 23 | pointless_create_value_t pointless_value_create_bool_true(); 24 | pointless_create_value_t pointless_value_create_null(); 25 | pointless_create_value_t pointless_value_create_empty_slot(); 26 | 27 | // read-time values 28 | pointless_value_t pointless_value_create_as_read_i32(int32_t v); 29 | pointless_value_t pointless_value_create_as_read_u32(uint32_t v); 30 | pointless_value_t pointless_value_create_as_read_float(float v); 31 | 32 | pointless_value_t pointless_value_create_as_read_bool_false(); 33 | pointless_value_t pointless_value_create_as_read_bool_true(); 34 | pointless_value_t pointless_value_create_as_read_null(); 35 | pointless_value_t pointless_value_create_as_read_empty_slot(); 36 | 37 | // hash/cmp-time values 38 | 39 | // ...create 40 | pointless_complete_create_value_t pointless_complete_value_create_i32(int32_t v); 41 | pointless_complete_create_value_t pointless_complete_value_create_u32(uint32_t v); 42 | pointless_complete_create_value_t pointless_complete_value_create_i64(int64_t v); 43 | pointless_complete_create_value_t pointless_complete_value_create_u64(uint64_t v); 44 | pointless_complete_create_value_t pointless_complete_value_create_float(float v); 45 | pointless_complete_create_value_t pointless_complete_value_create_null(); 46 | 47 | // ...read 48 | pointless_complete_value_t pointless_complete_value_create_as_read_i32(int32_t v); 49 | pointless_complete_value_t pointless_complete_value_create_as_read_u32(uint32_t v); 50 | pointless_complete_value_t pointless_complete_value_create_as_read_i64(int64_t v); 51 | pointless_complete_value_t pointless_complete_value_create_as_read_u64(uint64_t v); 52 | pointless_complete_value_t pointless_complete_value_create_as_read_float(float v); 53 | pointless_complete_value_t pointless_complete_value_create_as_read_null(); 54 | 55 | // read-time accessors 56 | int32_t pointless_value_get_i32(uint32_t t, pointless_value_data_t* v); 57 | uint32_t pointless_value_get_u32(uint32_t t, pointless_value_data_t* v); 58 | float pointless_value_get_float(uint32_t t, pointless_value_data_t* v); 59 | uint32_t pointless_value_get_bool(uint32_t t, pointless_value_data_t* v); 60 | int64_t pointless_get_int_as_int64(uint32_t t, pointless_value_data_t* v); 61 | 62 | // create-time accessor 63 | int64_t pointless_create_get_int_as_int64(pointless_create_value_t* v); 64 | int32_t pointless_create_value_get_i32(pointless_create_value_t* v); 65 | uint32_t pointless_create_value_get_u32(pointless_create_value_t* v); 66 | float pointless_create_value_get_float(pointless_create_value_t* v); 67 | 68 | // hash-time accessor 69 | int64_t pointless_complete_value_get_as_i64(uint32_t t, pointless_complete_value_data_t* v); 70 | uint64_t pointless_complete_value_get_as_u64(uint32_t t, pointless_complete_value_data_t* v); 71 | float pointless_complete_value_get_float(uint32_t t, pointless_complete_value_data_t* v); 72 | 73 | // conversions 74 | pointless_value_t pointless_value_from_complete(pointless_complete_value_t* a); 75 | pointless_complete_value_t pointless_value_to_complete(pointless_value_t* a); 76 | 77 | pointless_create_value_t pointless_create_value_from_complete(pointless_complete_create_value_t* a); 78 | pointless_complete_create_value_t pointless_create_value_to_complete(pointless_create_value_t* a); 79 | 80 | // utilities 81 | int32_t pointless_is_vector_type(uint32_t type); 82 | int32_t pointless_is_integer_type(uint32_t type); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/pointless/pointless_walk.h: -------------------------------------------------------------------------------- 1 | #ifndef __POINTLESS__WALK__H__ 2 | #define __POINTLESS__WALK__H__ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | typedef uint32_t (*pointless_walk_cb)(pointless_t* p, pointless_value_t* v, uint32_t depth, void* user); 10 | 11 | #define POINTLESS_WALK_VISIT_CHILDREN 0 12 | #define POINTLESS_WALK_MOVE_UP 1 13 | #define POINTLESS_WALK_STOP 2 14 | 15 | void pointless_walk(pointless_t* p, pointless_walk_cb cb, void* user); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /judy-1.0.5/AUTHORS: -------------------------------------------------------------------------------- 1 | Doug Baskinks 2 | Owner and Main Author 3 | 4 | Contributors: 5 | 6 | Troy Heber: 7 | Repackaging 8 | Project Administration 9 | -------------------------------------------------------------------------------- /judy-1.0.5/ChangeLog: -------------------------------------------------------------------------------- 1 | 1.0.5 Version (May 2007) by (twh) 2 | o added proper clean targets to enable multiple builds 3 | o added examples directory 4 | o Correctly Detects 32/64-bit build environment 5 | o Allow explicit configure for 32/64-bit environment 6 | 7 | 1.0.4 Version (May 2007) by (twh) 8 | o fixed the Checkit problem "error Judy1PrevEmpty Rcode != 1 = 0" 9 | o Fixed memory allignment in JudyMallocIF.c (doug) 10 | o Fixed messages from "make check" (doug). 11 | 12 | 1.0.3 Version (Feb 2006 ) by (twh) 13 | o fixed make files to break out each copy element 14 | to be a unique target, this also seems to have 15 | resolved the issue where running make check rebuilds 16 | the entire library again. 17 | 18 | 1.0.2 Version (Jan 2006 ) by (twh) 19 | 20 | o fixed assumption of signed char in test programs. 21 | o updated sh_build 22 | o fixed generation of man pages from html 23 | o fixed 32-bit and 64-bit configure 24 | 25 | 1.0.1 Version (Dec 2004) by (twh) 26 | 27 | o fixed bootstrap to use later versions 28 | o fixed manpage naming from (3X) to (3) 29 | o Code changes to support Microsoft __inline directive 30 | o Move away from using symlinks to using copies 31 | o Added build.bat to support building on Windows 32 | 33 | 1.0.0 Version (Sept 2004) by (twh) 34 | 35 | o Complete Autoconfisication of Judy 36 | o Removed previous build environment 37 | o Change INSTALL_IT back to INSTALL 38 | o Moving to 1.0.0 to denote API change. 39 | 40 | 41 | 0.1.6 Version (1June2004) by (dlb) 42 | 43 | o See src/sh_build in case of 'make' failures 44 | o The is an endian-neutral version I.E. (jp_DcdPop0 deleted) 45 | o Should not require any special platform specific compile flags 46 | o Includes JudyHS*() -- very fast, scalable string version 47 | o JudyHS*() is still preliminary and may need additional functionality. 48 | o See test/manual/StringCompare.c for comparing different 'string' ADT's 49 | o Deleted files: JudyMalloc.h, JudySL.h, JudySearch* 50 | o All malloc() and free() is done thru interface routines in JudyMalloc.c 51 | o Judy.h should work on all platforms that conform to ISO standards. 52 | o After trying on many platforms, was changed to 53 | o jbgraph has some 'bash/ksh' isms that need to be removed. 54 | o See test/manual/testjbgraph for plotting performance graphs 55 | o 'libtools' stuff is in unknown shape. 56 | o Does not "mangle" the root pointer (so old valgrind is not confused) 57 | o Conform to standard "C" 58 | o Change INSTALL to INSTALL_IT because it confused "make install" 59 | o To he man pages need work to clean up the .html to be portable 60 | o Plus hundreds of changes to make the source more portable. 61 | -------------------------------------------------------------------------------- /judy-1.0.5/INSTALL: -------------------------------------------------------------------------------- 1 | === QUICK INSTALLATION OF JUDY LIBRARY AND MANUAL ENTRIES === 2 | 3 | 1. ./configure #NOTE: you must do configure with either 4 | --enable-32-bit or --enable-64-bit 5 | depending on your system. Also note if you 6 | are doing a non-native compile you are 7 | responsiable for setting the appropriate 8 | CFLAGS. See README for more information. 9 | 2. make 10 | 3. make check 11 | 4. make install # NOTE: must be SUPERUSER for make install 12 | # This installs /opt/Judy/* and symlinks to 13 | # files there from /usr/include/, /usr/lib/, 14 | # /usr/share/man/, and /usr/share/doc/Judy/. 15 | 16 | (Installation done! The rest is optional but recommended.) 17 | 18 | 5) man Judy # nroff -man version, or... 19 | 20 | 6) file:/opt/Judy/usr/share/doc/Judy/Judy_3x.htm # from LOCAL Web browser. 21 | -------------------------------------------------------------------------------- /judy-1.0.5/Makefile.am: -------------------------------------------------------------------------------- 1 | # Tell automake we don't want to comply with every last clause in the 2 | # GNU Maintainer's Manual. 3 | AUTOMAKE_OPTIONS = foreign 4 | 5 | # We need to build the following subdirectories in this order. Note that 6 | # we put a Makefile.am in every subdirectory, even if there's nothing to 7 | # compile, so that we can support 'make dist' gracefully. 8 | # 9 | # Dependencies: src <- tool (for libJudy), tool <- doc (for jhton), src <- 10 | # test (for libJudy). 11 | #SUBDIRS = src tool doc test make_includes 12 | #SUBDIRS = src/JudyCommon src/JudyL src/Judy1 src/JudySL src/JudyHS src/obj 13 | SUBDIRS = src tool doc test 14 | 15 | # These files will be included in our tarballs, even though automake knows 16 | # nothing else about them. 17 | #EXTRA_DIST = Makefile.multi original_configure .cvsignore 18 | 19 | DISTCLEANFILES = config.log config.status Makefile libtool make.out 20 | -------------------------------------------------------------------------------- /judy-1.0.5/README: -------------------------------------------------------------------------------- 1 | 2 | Judy - C library creating and accessing dynamic arrays 3 | ============================================================== 4 | 5 | Content 6 | --------- 7 | 8 | 1. Introduction 9 | 2. Directory Contents 10 | 3. How to install 11 | 4. License 12 | 5. Change History 13 | 6. Reporting Bugs 14 | 7. Known Issues 15 | 16 | 17 | 1. INTRODUCTION 18 | ----------------- 19 | 20 | This tree contains sources, documents, tests, and tools for the Judy package. 21 | This file is in a form that can be validated using the tool/readme script. 22 | 23 | NOTE: The README files here describe some files that are not included in 24 | every Judy source package. 25 | 26 | WHAT IS JUDY? (see below for list of top-level directories and files) 27 | 28 | Judy is a C library that implements a dynamic array. Empty Judy arrays are 29 | declared with null pointers. A Judy array consumes memory only when 30 | populated yet can grow to take advantage of all available memory. Judy's key 31 | benefits are: scalability, performance, memory efficiency, and ease of use. 32 | Judy arrays are designed to grow without tuning into the peta-element range, 33 | scaling near O(log-base-256) -- 1 more RAM access at 256 X population. 34 | 35 | Judy arrays are accessed with insert, retrieve, and delete calls for number 36 | or string indexes. Configuration and tuning are not required -- in fact not 37 | possible. Judy offers sorting, counting, and neighbor/empty searching. 38 | Indexes can be sequential, clustered, periodic, or random -- it doesn't 39 | matter to the algorithm. Judy arrays can be arranged hierarchically to 40 | handle any bit patterns -- large indexes, sets of keys, etc. 41 | 42 | Judy is often an improvement over common data structures such as: arrays, 43 | sparse arrays, hash tables, B-trees, binary trees, linear lists, skiplists, 44 | other sort and search algorithms, and counting functions. 45 | 46 | 47 | 2. JUDY TOP DIRECTORY CONTENTS: 48 | -------------------------------- 49 | 50 | AUTHORS Judy authors and contributors 51 | README This file. 52 | INSTALL Summary instructions to build, check and install Judy. 53 | COPYING Judy deliverable license notice (the LGPL). 54 | ChangeLog List of changes per version of Judy. 55 | 56 | configure Autoconf configure script to allow a portable build e 57 | environment. 58 | 59 | src/ Header and source files used to build the package. 60 | doc/ Documents, both external (to the package) and internal. 61 | test/ Test support and some timing programs. 62 | tool/ Primitive tool (jhton) to convert *.html files to "man" pages. 63 | and build tables used by Judy to malloc() sizes of memory. 64 | 65 | 3. HOW TO INSTALL 66 | ----------------- 67 | 68 | For a quick description see the INSTALL file. 69 | 70 | Judy is now based on the GNU Auto tools. This means that you can do the standard 71 | configure, make, make check and make install and everything should work, with 72 | one minor difference and a little caveat. 73 | 74 | Judy is capable of being built as a 32-bit or a 64-bit library. Configure 75 | will test to detect the native environment and default to that. Therefor if you 76 | explicitly want to to compile for the non-native environment you need to tell 77 | Judy what you want. You can run ./configure with one of the following flags: 78 | 79 | --enable-32-bit 80 | --enable-64-bit 81 | 82 | The caveat comes in on machines that support both at 32-bit and 64-bit runtime 83 | environments such as RISC platforms and x86-64. In this case your compiler will 84 | either use 32-bit or 64-bit as default. If you plan to use the default you can 85 | follow the above instructions and be finished. 86 | 87 | However, if you wish to compile for the non-default target type. YOU ARE 88 | RESPONSIBLE FOR SETTING THE CORRECT FLAGS! Such as CFLAGS to make your compiler 89 | switch modes LDFLAGS to make your linker behave, etc. 90 | 91 | For example: On HP-UX PA-RISC the compiler generates 32-bit code by default. If 92 | I wish to stick with the defaults I can simply build Judy by: 93 | ./configure 94 | make 95 | make check 96 | make install 97 | 98 | If I want to build Judy as a 64-bit library on HP-UX PA-RISC I have to do: 99 | CFLAGS=+DD64 ./configure --enable-64-bit 100 | make 101 | make check 102 | make install 103 | 104 | If I want to build Judy native (64-bit) on Linux AMD64 I have to do: 105 | ./configure 106 | make 107 | make check 108 | make install 109 | 110 | If I want to build Judy 32-bit on Linux AMD64 I have to do: 111 | ./configure --enable-32-bit 112 | make 113 | make check 114 | make install 115 | 116 | 4. LICENSE 117 | ---------- 118 | 119 | The user library is licensed under the GNU Lesser Public License (LGPL) 120 | Version 2.1, February 1999. The full text of the LGPL is located at: 121 | 122 | COPYING 123 | 124 | 125 | 5. CHAGE HISTORY 126 | ---------------- 127 | 128 | See the ChangeLog file. 129 | 130 | 6. REPORTING BUGS 131 | ----------------- 132 | 133 | If you encounter a bug, please submit it to the project bug list, 134 | located on the project page: 135 | 136 | https://sourceforge.net/projects/judy/ 137 | 138 | 7. KNOWN ISSUES 139 | --------------- 140 | 141 | When compiling on HP-UX, you may get a message like: 142 | error 1000: Unexpected symbol: 143 | 144 | This is a problem with the HP's compiler in that it doesn't like a typedef'ed 145 | type following a static inline. 146 | 147 | You can work around it by running this command from the Judy directory. 148 | 149 | find ./ -name \*.[ch] | xargs perl -i.BAK -pe 's/static inline/static/g' 150 | -------------------------------------------------------------------------------- /judy-1.0.5/bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | set -x 3 | 4 | libtoolize --force --copy 5 | #aclocal-1.9 6 | aclocal 7 | #autoheader2.50 8 | autoheader 9 | #add --include-deps if you want to bootstrap with any other compiler than gcc 10 | #automake --add-missing --copy --include-deps 11 | automake-1.9 --add-missing --force --copy 12 | #autoconf2.50 13 | autoconf 14 | rm -f config.cache 15 | -------------------------------------------------------------------------------- /judy-1.0.5/compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand `-c -o'. 3 | 4 | scriptversion=2005-05-14.22 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | case $1 in 33 | '') 34 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 35 | exit 1; 36 | ;; 37 | -h | --h*) 38 | cat <<\EOF 39 | Usage: compile [--help] [--version] PROGRAM [ARGS] 40 | 41 | Wrapper for compilers which do not understand `-c -o'. 42 | Remove `-o dest.o' from ARGS, run PROGRAM with the remaining 43 | arguments, and rename the output as expected. 44 | 45 | If you are trying to build a whole package this is not the 46 | right script to run: please start by reading the file `INSTALL'. 47 | 48 | Report bugs to . 49 | EOF 50 | exit $? 51 | ;; 52 | -v | --v*) 53 | echo "compile $scriptversion" 54 | exit $? 55 | ;; 56 | esac 57 | 58 | ofile= 59 | cfile= 60 | eat= 61 | 62 | for arg 63 | do 64 | if test -n "$eat"; then 65 | eat= 66 | else 67 | case $1 in 68 | -o) 69 | # configure might choose to run compile as `compile cc -o foo foo.c'. 70 | # So we strip `-o arg' only if arg is an object. 71 | eat=1 72 | case $2 in 73 | *.o | *.obj) 74 | ofile=$2 75 | ;; 76 | *) 77 | set x "$@" -o "$2" 78 | shift 79 | ;; 80 | esac 81 | ;; 82 | *.c) 83 | cfile=$1 84 | set x "$@" "$1" 85 | shift 86 | ;; 87 | *) 88 | set x "$@" "$1" 89 | shift 90 | ;; 91 | esac 92 | fi 93 | shift 94 | done 95 | 96 | if test -z "$ofile" || test -z "$cfile"; then 97 | # If no `-o' option was seen then we might have been invoked from a 98 | # pattern rule where we don't need one. That is ok -- this is a 99 | # normal compilation that the losing compiler can handle. If no 100 | # `.c' file was seen then we are probably linking. That is also 101 | # ok. 102 | exec "$@" 103 | fi 104 | 105 | # Name of file we expect compiler to create. 106 | cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 107 | 108 | # Create the lock directory. 109 | # Note: use `[/.-]' here to ensure that we don't use the same name 110 | # that we are using for the .o file. Also, base the name on the expected 111 | # object file name, since that is what matters with a parallel build. 112 | lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 113 | while true; do 114 | if mkdir "$lockdir" >/dev/null 2>&1; then 115 | break 116 | fi 117 | sleep 1 118 | done 119 | # FIXME: race condition here if user kills between mkdir and trap. 120 | trap "rmdir '$lockdir'; exit 1" 1 2 15 121 | 122 | # Run the compile. 123 | "$@" 124 | ret=$? 125 | 126 | if test -f "$cofile"; then 127 | mv "$cofile" "$ofile" 128 | elif test -f "${cofile}bj"; then 129 | mv "${cofile}bj" "$ofile" 130 | fi 131 | 132 | rmdir "$lockdir" 133 | exit $ret 134 | 135 | # Local Variables: 136 | # mode: shell-script 137 | # sh-indentation: 2 138 | # eval: (add-hook 'write-file-hooks 'time-stamp) 139 | # time-stamp-start: "scriptversion=" 140 | # time-stamp-format: "%:y-%02m-%02d.%02H" 141 | # time-stamp-end: "$" 142 | # End: 143 | -------------------------------------------------------------------------------- /judy-1.0.5/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ 7 | #undef HAVE_DOPRNT 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_FCNTL_H 11 | 12 | /* Define to 1 if you have the `getpagesize' function. */ 13 | #undef HAVE_GETPAGESIZE 14 | 15 | /* Define to 1 if you have the `gettimeofday' function. */ 16 | #undef HAVE_GETTIMEOFDAY 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_INTTYPES_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_LIMITS_H 23 | 24 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 25 | to 0 otherwise. */ 26 | #undef HAVE_MALLOC 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #undef HAVE_MALLOC_H 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #undef HAVE_MEMORY_H 33 | 34 | /* Define to 1 if you have the `memset' function. */ 35 | #undef HAVE_MEMSET 36 | 37 | /* Define to 1 if you have a working `mmap' system call. */ 38 | #undef HAVE_MMAP 39 | 40 | /* Define to 1 if you have the `munmap' function. */ 41 | #undef HAVE_MUNMAP 42 | 43 | /* Define to 1 if you have the `pow' function. */ 44 | #undef HAVE_POW 45 | 46 | /* Define to 1 if the system has the type `ptrdiff_t'. */ 47 | #undef HAVE_PTRDIFF_T 48 | 49 | /* Define to 1 if `stat' has the bug that it succeeds when given the 50 | zero-length file name argument. */ 51 | #undef HAVE_STAT_EMPTY_STRING_BUG 52 | 53 | /* Define to 1 if stdbool.h conforms to C99. */ 54 | #undef HAVE_STDBOOL_H 55 | 56 | /* Define to 1 if you have the header file. */ 57 | #undef HAVE_STDDEF_H 58 | 59 | /* Define to 1 if you have the header file. */ 60 | #undef HAVE_STDINT_H 61 | 62 | /* Define to 1 if you have the header file. */ 63 | #undef HAVE_STDLIB_H 64 | 65 | /* Define to 1 if you have the `strchr' function. */ 66 | #undef HAVE_STRCHR 67 | 68 | /* Define to 1 if you have the `strcspn' function. */ 69 | #undef HAVE_STRCSPN 70 | 71 | /* Define to 1 if you have the `strerror' function. */ 72 | #undef HAVE_STRERROR 73 | 74 | /* Define to 1 if you have the header file. */ 75 | #undef HAVE_STRINGS_H 76 | 77 | /* Define to 1 if you have the header file. */ 78 | #undef HAVE_STRING_H 79 | 80 | /* Define to 1 if you have the `strstr' function. */ 81 | #undef HAVE_STRSTR 82 | 83 | /* Define to 1 if you have the `strtoul' function. */ 84 | #undef HAVE_STRTOUL 85 | 86 | /* Define to 1 if you have the header file. */ 87 | #undef HAVE_SYS_PARAM_H 88 | 89 | /* Define to 1 if you have the header file. */ 90 | #undef HAVE_SYS_STAT_H 91 | 92 | /* Define to 1 if you have the header file. */ 93 | #undef HAVE_SYS_TIME_H 94 | 95 | /* Define to 1 if you have the header file. */ 96 | #undef HAVE_SYS_TYPES_H 97 | 98 | /* Define to 1 if you have the `uname' function. */ 99 | #undef HAVE_UNAME 100 | 101 | /* Define to 1 if you have the header file. */ 102 | #undef HAVE_UNISTD_H 103 | 104 | /* Define to 1 if you have the `vprintf' function. */ 105 | #undef HAVE_VPRINTF 106 | 107 | /* Define to 1 if the system has the type `_Bool'. */ 108 | #undef HAVE__BOOL 109 | 110 | /* Define to 1 on little-endian systems. */ 111 | #undef JU_LITTLE_ENDIAN 112 | 113 | /* Define to 1 if `lstat' dereferences a symlink specified with a trailing 114 | slash. */ 115 | #undef LSTAT_FOLLOWS_SLASHED_SYMLINK 116 | 117 | /* Name of package */ 118 | #undef PACKAGE 119 | 120 | /* Define to the address where bug reports for this package should be sent. */ 121 | #undef PACKAGE_BUGREPORT 122 | 123 | /* Define to the full name of this package. */ 124 | #undef PACKAGE_NAME 125 | 126 | /* Define to the full name and version of this package. */ 127 | #undef PACKAGE_STRING 128 | 129 | /* Define to the one symbol short name of this package. */ 130 | #undef PACKAGE_TARNAME 131 | 132 | /* Define to the version of this package. */ 133 | #undef PACKAGE_VERSION 134 | 135 | /* The size of `void *', as computed by sizeof. */ 136 | #undef SIZEOF_VOID_P 137 | 138 | /* Define to 1 if you have the ANSI C header files. */ 139 | #undef STDC_HEADERS 140 | 141 | /* Define to 1 if you can safely include both and . */ 142 | #undef TIME_WITH_SYS_TIME 143 | 144 | /* Define to 1 if your declares `struct tm'. */ 145 | #undef TM_IN_SYS_TIME 146 | 147 | /* Version number of package */ 148 | #undef VERSION 149 | 150 | /* Define to 1 if your processor stores words with the most significant byte 151 | first (like Motorola and SPARC, unlike Intel and VAX). */ 152 | #undef WORDS_BIGENDIAN 153 | 154 | /* Define to empty if `const' does not conform to ANSI C. */ 155 | #undef const 156 | 157 | /* Define to `__inline__' or `__inline' if that's what the C compiler 158 | calls it, or to nothing if 'inline' is not supported under any name. */ 159 | #ifndef __cplusplus 160 | #undef inline 161 | #endif 162 | 163 | /* Define to rpl_malloc if the replacement function should be used. */ 164 | #undef malloc 165 | 166 | /* Define to `unsigned int' if does not define. */ 167 | #undef size_t 168 | 169 | /* Define to empty if the keyword `volatile' does not work. Warning: valid 170 | code using `volatile' can become incorrect without. Disable with care. */ 171 | #undef volatile 172 | -------------------------------------------------------------------------------- /judy-1.0.5/doc/ext/COPYRIGHT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arnimarj/py-pointless/c0492312bd7cf34a29c367fb699980afc18016b9/judy-1.0.5/doc/ext/COPYRIGHT -------------------------------------------------------------------------------- /judy-1.0.5/doc/ext/JudyHS_funcs_3.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JudyHS_funcs(3) 5 | 6 | 7 | 8 | 9 | 10 | 11 |
JudyHS_funcs(3) JudyHS_funcs(3)
12 |

13 |

14 | 15 |
NAME
16 |
17 | JudyHS functions - 18 | C library for creating and accessing a dynamic array, 19 | using an array-of-bytes of a length: Length as an Index and a word 20 | as a Value. 21 | 22 |

23 |

SYNOPSIS
24 |
25 |
 26 | PPvoid_t JudyHSIns(PPvoid_t PPJHS, void *Index, Word_t Length, PJError_t PJError);
 27 | int      JudyHSDel(PPvoid_t PPJHS, void *Index, Word_t Length, PJError_t PJError);
 28 | PPvoid_t JudyHSGet(Pcvoid_t  PJHS, void *Index, Word_t Length, PJError_t PJError);
 29 | Word_t   JudyHSFreeArray(PPvoid_t PPJHS, PJError_t PJError);
 30 | 
31 | 32 |

33 |

DESCRIPTION
34 |
35 | A macro equivalent exists for each function call. Because the macro 36 | forms are sometimes faster and have a simpler error handling interface 37 | than the equivalent functions, they are the preferred way of calling the 38 | JudyHS functions. 39 | See JudyHS(3) 40 | for more information. 41 | The function call definitions are included here for completeness. 42 |

43 | One of the difficulties in using the JudyHS function calls lies in 44 | determining whether to pass a pointer or the address of a pointer. 45 | Since the functions that modify the JudyHS array must also modify the 46 | pointer to the JudyHS array, you must pass the address of the pointer 47 | rather than the pointer itself. 48 | This often leads to hard-to-debug programmatic errors. 49 | In practice, the macros allow the compiler to catch programming 50 | errors when pointers instead of addresses of pointers are passed. 51 |

52 | The JudyHS function calls have an additional parameter beyond those 53 | specified in the macro calls. This parameter is either a pointer to an 54 | error structure, or NULL (in which case the error information is 55 | not returned -- only PJERR in the return parameter). 56 |

57 | In the following descriptions, the functions are described in 58 | terms of how the macros use them. 59 | This is the suggested use 60 | of the macros after your program has been fully debugged. 61 | When the JUDYERROR_NOTEST macro is not specified, 62 | an error structure is declared to store error information 63 | returned from the JudyHS functions when an error occurs. 64 |

65 | Notice the placement of the & in the different functions. 66 |

67 |

68 |
JudyHSIns(&PJHS, Index, Length, &JError)
69 |
70 |
 71 | #define JHSI(PValue, PJHS, Index) \
 72 |    PValue = JudyLIns(&PJHS, Index, PJE0)
 73 | 
 74 | 
75 |

76 |

JudyHSDel(&PJHS, Index, Length, &JError)
77 |
78 |
 79 | #define JHSD(Rc_int, PJHS, Index, Length) \
 80 |    Rc_int = JudyHSDel(&PJHS, Index, Length, PJE0)
 81 | 
 82 | 
83 |

84 |

JudyHSGet(PJHS, Index, Length)
85 |
86 |
 87 | #define JHSG(PValue, PJHS, Index, Length) \
 88 |    PValue = JudyHSIns(PJHS, Index, Length)
 89 | 
 90 | 
91 |

92 |

JudyHSFreeArray(&PJHS, &JError)
93 |
94 |
 95 | #define JHSFA(Rc_word, PJHS) \
 96 |    Rc_word = JudyHSFreeArray(&PJHS, PJE0)
 97 | 
 98 | 
99 |
100 |

101 | Definitions for all the Judy functions, the types 102 | Pvoid_t, 103 | Pcvoid_t, 104 | PPvoid_t, 105 | Word_t , 106 | JError_t, 107 | and 108 | PJError_t, 109 | the constants 110 | NULL, 111 | JU_ERRNO_*, 112 | JERR, 113 | PPJERR, 114 | and 115 | PJE0 116 | are provided in the Judy.h header file 117 | (/usr/include/Judy.h). 118 | Note: Callers should define JudyHS arrays as type Pvoid_t, 119 | which can be passed by value to functions that take 120 | Pcvoid_t (constant Pvoid_t), 121 | and also by address to functions that take PPvoid_t. 122 |

123 | The return type from most JudyHS functions is PPvoid_t so 124 | that the values stored in the array can be pointers to other objects, 125 | which is a typical usage, or cast to a Word_t * when a pointer 126 | to a value is required instead of a pointer to a pointer. 127 | 128 |

129 |

AUTHOR
130 |
131 | JudyHS was invented and implemented by Doug Baskins after retiring from Hewlett-Packard. 132 | 133 |

134 |

SEE ALSO
135 |
136 | Judy(3), 137 | Judy1(3), 138 | JudyL(3), 139 | JudySL(3), 140 | JudyHS(3), 141 |
142 | malloc(), 143 |
144 | the Judy website, 145 | 146 | http://judy.sourceforge.net, 147 | for more information and Application Notes. 148 |
149 | 150 | 151 | -------------------------------------------------------------------------------- /judy-1.0.5/doc/ext/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arnimarj/py-pointless/c0492312bd7cf34a29c367fb699980afc18016b9/judy-1.0.5/doc/ext/LICENSE -------------------------------------------------------------------------------- /judy-1.0.5/doc/ext/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.11 $ 2 | 3 | Judy_3.htm the Judy(3) overview manual entry in HTML format; 4 | normally placed where a web browser can read it 5 | 6 | Judy1_3.htm describes the Judy1*() macros 7 | Judy1_funcs_3.htm describes the Judy1*() functions 8 | JudyL_3.htm describes the JudyL*() macros 9 | JudyL_funcs_3.htm describes the JudyL*() functions 10 | JudySL_3.htm describes the JudySL*() macros 11 | JudySL_funcs_3.htm describes the JudySL*() functions 12 | JudyHS_3.htm describes the JudyHS*() macros 13 | JudyHS_funcs_3.htm describes the JudyHS*() functions 14 | 15 | # Note: The library package README file comes from the following file, but the 16 | # hierarchy of example sources package README files come from each 17 | # corresponding directory: 18 | 19 | README_deliver packaged with other Judy delivered files, renamed to just 20 | "README" in that context 21 | -------------------------------------------------------------------------------- /judy-1.0.5/doc/ext/README_deliver: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.11 $ 2 | 3 | Judy_3.htm the Judy(3) overview manual entry in HTML format; 4 | normally placed where a web browser can read it 5 | 6 | Judy1_3.htm describes the Judy1*() macros 7 | Judy1_funcs_3.htm describes the Judy1*() functions 8 | JudyL_3.htm describes the JudyL*() macros 9 | JudyL_funcs_3.htm describes the JudyL*() functions 10 | JudySL_3.htm describes the JudySL*() macros 11 | JudySL_funcs_3.htm describes the JudySL*() functions 12 | JudyHS_3.htm describes the JudyHS*() macros 13 | JudyHS_funcs_3.htm describes the JudyHS*() functions 14 | 15 | # Note: The library package README file comes from the following file, but the 16 | # hierarchy of example sources package README files come from each 17 | # corresponding directory: 18 | 19 | README_deliver packaged with other Judy delivered files, renamed to just 20 | "README" in that context 21 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Judy1Dup.c: -------------------------------------------------------------------------------- 1 | /* @(#) $Revision: 4.2 $ $Source: /judy/src/funcs/Judy1Dup.c $ */ 2 | 3 | #include "Judy.h" 4 | 5 | /******************************************************************* 6 | * Name: Judy1Dup 7 | * 8 | * Description: 9 | * Clone (duplicate) a Judy Array. 10 | * 11 | * Parameters: 12 | * PPvoid_t PPDest (OUT) 13 | * Pointer to a new Judy array with the same 14 | * index/value pairs as PSource. 15 | * Any initial value pointed to by PPDest is ignored. 16 | * 17 | * Pvoid_t PSource (IN) 18 | * Ptr to source Judy array being duplicated. 19 | * If PSource is NULL, TRUE is returned since this 20 | * is simply a valid Null Judy array. 21 | * 22 | * JError_t *PJError (OUT) 23 | * Judy error structure pointer. 24 | * 25 | * Returns: 26 | * JERR - error, see PJError 27 | * !JERR - success 28 | */ 29 | 30 | int 31 | Judy1Dup(PPvoid_t PPDest, Pvoid_t PSource, JError_t * PJError) 32 | { 33 | Pvoid_t newJArray = 0; // new Judy1 array to ppopulate 34 | Word_t kindex; // Key/index 35 | int Ins_rv = 0; // Insert return value 36 | 37 | for (kindex = 0L, Ins_rv = Judy1First(PSource, &kindex, PJError); 38 | Ins_rv == 1; Ins_rv = Judy1Next(PSource, &kindex, PJError)) 39 | { 40 | Ins_rv = Judy1Set(&newJArray, kindex, PJError); 41 | } 42 | if (Ins_rv == JERR) 43 | return Ins_rv; 44 | 45 | *PPDest = newJArray; 46 | return Ins_rv; 47 | } /* Judy1Dup */ 48 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Judy1Dup.h: -------------------------------------------------------------------------------- 1 | /* @(#) $Revision: 4.2 $ $Source: /judy/src/funcs/Judy1Dup.H $ */ 2 | 3 | #include 4 | 5 | /* ****************************************************************** 6 | * Name: Judy1Dup 7 | * 8 | * Description: 9 | * Clone (duplicate) a Judy Array. 10 | * 11 | * Parameters: 12 | * PPvoid_t PPDest (OUT) 13 | * Pointer to a new Judy array with the same 14 | * index/value pairs as PSource. 15 | * Any initial value pointed to by PPDest is ignored. 16 | * 17 | * Pvoid_t PSource (IN) 18 | * Ptr to source Judy array being duplicated. 19 | * If PSource is NULL, TRUE is returned since this 20 | * is simply a valid Null Judy array. 21 | * 22 | * JError_t *PJError (OUT) 23 | * Judy error structure pointer. 24 | * 25 | * Returns: 26 | * JERR - error, see PJError 27 | * !JERR - success 28 | */ 29 | 30 | int 31 | Judy1Dup(PPvoid_t PPDest, Pvoid_t PSource, JError_t * PJError); 32 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Judy1DupCheck.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * @(#) $Revision: 4.3 $ $Source: /judy/src/funcs/Judy1DupCheck.c $ 4 | * 5 | * Judy1DupCheck.c 6 | * 7 | * Test Judy1Dup.c 8 | */ 9 | 10 | #include 11 | #include 12 | #include "Judy1Dup.h" 13 | 14 | #define LARRAYSIZE(array) sizeof(array)/sizeof(Word_t) 15 | 16 | // fcn to init a Judy array with an array of ulong's 17 | Pvoid_t 18 | ularray2Judy(Word_t *ularray, Word_t ularray_size) 19 | { 20 | Word_t i; 21 | Pvoid_t PJArray = 0; 22 | JError_t JError; 23 | 24 | for (i = 0L; i < ularray_size; i++) 25 | { 26 | if (Judy1Set(&PJArray, ularray[i], &JError) == JERR) 27 | { 28 | printf("ularray2Judy: Judy1Set failure, error %d\n", 29 | JU_ERRNO(&JError)); 30 | exit(2); 31 | } 32 | } 33 | return PJArray; 34 | } /* ularray2Judy */ 35 | 36 | int 37 | main() 38 | { 39 | static Word_t knowns[] = { 0, 1, 1024, 4095, 4096, 4097, 4098, 123456 }; 40 | int i; 41 | Pvoid_t PJArray = 0; 42 | Pvoid_t PJArrayNew = 0; 43 | Word_t Index; 44 | int Judy_rv; // Judy Return value 45 | JError_t JError; 46 | 47 | // populate a judy array with known values 48 | PJArray = ularray2Judy(knowns, LARRAYSIZE(knowns)); 49 | 50 | printf("Testing Judy1Dup ..."); 51 | 52 | // dup the judy array 53 | if ((Judy1Dup(&PJArrayNew, PJArray, &JError)) == JERR) 54 | { 55 | printf("Judy1Dup failed: error %d\n", JU_ERRNO(&JError)); 56 | return (2); 57 | } 58 | 59 | // compare the duped array with known values 60 | for (i = 0, Index = 0L, Judy_rv = Judy1First(PJArrayNew, &Index, &JError); 61 | Judy_rv == 1; i++, Judy_rv = Judy1Next(PJArrayNew, &Index, &JError)) 62 | { 63 | if (Index != knowns[i]) 64 | { 65 | printf("Judy1DupCheck Failed: Judy1Dup does not match original\n"); 66 | return (2); 67 | } 68 | } 69 | 70 | if (i != LARRAYSIZE(knowns)) 71 | { 72 | printf 73 | ("Judy1DupCheck Failed: Judy1Dup does not match original (too short)\n"); 74 | exit(2); 75 | } 76 | else 77 | printf("Ok\n"); 78 | 79 | return (0); 80 | } 81 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Judy1Op.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * @(#) $Revision: 4.2 $ $Source: /judy/src/funcs/Judy1Op.c $ 4 | * 5 | * Judy1 set operations. 6 | * 7 | * The name of this function, "Judy1Op", was carefully chosen from 8 | * a list of alternatives: 9 | * 10 | * Judy1Op() - It's hard to see that O is a letter and not a zero. 11 | * Judy1Set() - Sounds like you are setting a bit. 12 | * Judy1BS() - BS for Bit Set functions. 13 | * Judy1SO() - SO for Set Operations 14 | * Judy1AndIDontGiveADarn() - too long but goes with 15 | * Judy1WhoseOnFirst() - now called Judy1First() and 16 | * Judy1WhatsOnSecond() - now called Judy1Next() 17 | * 18 | * But Judy1SetOp() would conflict with Judy1Set() if we rename Judy1Set(), so 19 | * Judy1Op() it is. 20 | */ 21 | 22 | #include "Judy.h" 23 | #include "Judy1Op.h" 24 | 25 | /******************************************************************* 26 | * Name: Judy1Op 27 | * 28 | * Description: 29 | * Logical set operations on Judy1 arrays. 30 | * 31 | * All of these operations can be done on an unbounded array because 32 | * the dreaded "NOT" is avoided. The "NOT"'s can be implemented 33 | * when Judy1 supports them. 34 | * 35 | * Parameters: 36 | * PPvoid_t PPDest (OUT) 37 | * Ptr to the Judy destination array. 38 | * Any initial value pointed to by PPDest is ignored. 39 | * 40 | * Pvoid_t PSet1 (IN) 41 | * First Judy1 set. 42 | * This will be NULL for an empty Judy1 array. 43 | * 44 | * Pvoid_t PSet2 (IN) 45 | * Second Judy1 set. 46 | * This will be NULL for an empty Judy1 array. 47 | * 48 | * Word_t Operation (IN) 49 | * Operation to be performed (ie. PSet1 {Operation} PSet2) 50 | * Valid Operation values are: 51 | * 52 | * JUDY1OP_AND - intersection of two sets 53 | * JUDY1OP_OR - union of two sets 54 | * JUDY1OP_ANDNOT - set1 with set2 removed 55 | * 56 | * JError_t * PJError (OUT) 57 | * Judy Error struct used to return Judy error. 58 | * 59 | * Returns: 60 | * !JERR if successful 61 | * JERR if an error occurs 62 | * If the error is a caller error (invalid Operation or no PPDest) 63 | * then the PJError error code will be JU_ERRNO_NONE. 64 | */ 65 | int 66 | Judy1Op(PPvoid_t PPDest, Pvoid_t PSet1, Pvoid_t PSet2, 67 | Word_t Operation, JError_t * PJError) 68 | { 69 | Pvoid_t PnewJArray = 0; // empty Judy array 70 | Word_t Index1 = 0L; 71 | Word_t Index2 = 0L; 72 | int Judy_rv; 73 | 74 | if (!PPDest) 75 | return JERR; 76 | 77 | switch (Operation) 78 | { 79 | case JUDY1OP_AND: 80 | // step through each array looking for index matches 81 | Judy_rv = Judy1First(PSet1, &Index1, PJError); 82 | Judy_rv += Judy1First(PSet2, &Index2, PJError); 83 | while (Judy_rv == 2) 84 | { 85 | if (Index1 < Index2) 86 | { 87 | Index1 = Index2; 88 | Judy_rv = Judy1First(PSet1, &Index1, PJError); 89 | } 90 | else if (Index1 > Index2) 91 | { 92 | Index2 = Index1; 93 | Judy_rv = Judy1First(PSet2, &Index2, PJError); 94 | } 95 | else 96 | { 97 | // do the AND 98 | Judy_rv = Judy1Set(&PnewJArray, Index1, PJError); 99 | if (Judy_rv == JERR) 100 | return JERR; 101 | 102 | // bump to the next bits 103 | Judy_rv = Judy1Next(PSet1, &Index1, PJError); 104 | Judy_rv += Judy1Next(PSet2, &Index2, PJError); 105 | } 106 | } 107 | *PPDest = PnewJArray; 108 | break; 109 | 110 | case JUDY1OP_OR: 111 | /* Set all the bits from PSet1 */ 112 | for (Index1 = 0L, Judy_rv = Judy1First(PSet1, &Index1, PJError); 113 | Judy_rv == 1; Judy_rv = Judy1Next(PSet1, &Index1, PJError)) 114 | { 115 | if (Judy1Set(&PnewJArray, Index1, PJError) == JERR) 116 | return JERR; 117 | } 118 | 119 | /* Set all the bits from PSet2 */ 120 | for (Index1 = 0L, Judy_rv = Judy1First(PSet2, &Index1, PJError); 121 | Judy_rv == 1; Judy_rv = Judy1Next(PSet2, &Index1, PJError)) 122 | { 123 | if (Judy1Set(&PnewJArray, Index1, PJError) == JERR) 124 | return JERR; 125 | } 126 | *PPDest = PnewJArray; 127 | break; 128 | 129 | case JUDY1OP_ANDNOT: 130 | // PSet1 with PSet2 removed 131 | // 0010 = PSet1(1010) ANDNOT PSet2(1100) 132 | 133 | for (Index1 = 0L, Judy_rv = Judy1First(PSet1, &Index1, PJError); 134 | Judy_rv == 1; Judy_rv = Judy1Next(PSet1, &Index1, PJError)) 135 | { 136 | // if bit doesn't exist in PSet2, then add to result 137 | if (0 == Judy1Test(PSet2, Index1, PJError)) 138 | { 139 | if (Judy1Set(&PnewJArray, Index1, PJError) == JERR) 140 | return JERR; 141 | } 142 | } 143 | *PPDest = PnewJArray; 144 | break; 145 | 146 | default: 147 | return JERR; 148 | } 149 | return !JERR; 150 | } /* Judy1Op */ 151 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Judy1Op.h: -------------------------------------------------------------------------------- 1 | #ifndef _JUDY1OP_INCLUDED 2 | #define _JUDY1OP_INCLUDED 3 | 4 | // @(#) $Revision: 4.1 $ $Source: /judy/src/funcs/Judy1Op.h $ 5 | // 6 | // HEADER FILE FOR EXPORTED FEATURES FROM Judy1Op(). 7 | 8 | #define JUDY1OP_AND 1L 9 | #define JUDY1OP_OR 2L 10 | #define JUDY1OP_ANDNOT 3L 11 | 12 | extern int Judy1Op(PPvoid_t PPDest, Pvoid_t PSet1, Pvoid_t PSet2, 13 | Word_t Operation, JError_t * PJError); 14 | 15 | #endif // ! _JUDY1OP_INCLUDED 16 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Judy1OpCheck.c: -------------------------------------------------------------------------------- 1 | // @(#) $Revision: 4.3 $ $Source: /judy/src/funcs/Judy1OpCheck.c $ 2 | 3 | /* 4 | * Judy1OpCheck.c 5 | * 6 | * Test Judy1Op.c 7 | * 8 | * Returns 0 if successful, -1 if test fails. 9 | */ 10 | 11 | #include 12 | #include 13 | #include "Judy.h" 14 | #include "Judy1Op.h" 15 | 16 | #define LARRAYSIZE(array) sizeof(array)/sizeof(Word_t) 17 | 18 | static Word_t set1[] = { 0L, 19 | 5L, 20 | 6L, 21 | 7L, 22 | 1024L, 23 | 11111L, 24 | 65534L, 25 | 65535L, 26 | 65536L, 27 | 555555L, 28 | ULONG_MAX 29 | }; 30 | 31 | static Word_t set2[] = { 7L, 32 | 9L, 33 | 1023L, 34 | 12345L, 35 | 65535L, 36 | ULONG_MAX 37 | }; 38 | 39 | static Word_t resultAND[] = { 7L, 40 | 65535L, 41 | ULONG_MAX 42 | }; 43 | 44 | static Word_t resultOR[] = { 0L, 45 | 5L, 46 | 6L, 47 | 7L, 48 | 9L, 49 | 1023L, 50 | 1024L, 51 | 11111L, 52 | 12345L, 53 | 65534L, 54 | 65535L, 55 | 65536L, 56 | 555555L, 57 | ULONG_MAX 58 | }; 59 | 60 | static Word_t result1ANDNOT2[] = { 0L, 61 | 5L, 62 | 6L, 63 | 1024L, 64 | 11111L, 65 | 65534L, 66 | 65536L, 67 | 555555L 68 | }; 69 | 70 | static Word_t result2ANDNOT1[] = { 9L, 71 | 1023L, 72 | 12345L 73 | }; 74 | 75 | // fcn to init a Judy array with an array of ulong's 76 | void * 77 | ularray2Judy(Word_t *ularray, Word_t ularray_size) 78 | { 79 | Word_t i; 80 | void *PJArray = 0; 81 | JError_t JError; 82 | 83 | for (i = 0L; i < ularray_size; i++) 84 | { 85 | if (Judy1Set(&PJArray, ularray[i], &JError) == JERR) 86 | { 87 | printf("ularray2Judy: Judy1Set failure, error %d\n", 88 | JU_ERRNO(&JError)); 89 | exit(2); 90 | } 91 | } 92 | return PJArray; 93 | } /* ularray2Judy */ 94 | 95 | // fcn to test Judy1Op and check the results 96 | void 97 | testandcheck(void *PJSet1, void *PJSet2, Word_t operation, 98 | char *opstr, Word_t *result, int result_size) 99 | { 100 | void *PJArrayNew; 101 | Word_t Index; 102 | int i; 103 | int judy_rv = 0; 104 | JError_t JError; 105 | 106 | printf("Testing Judy1Op(%s) ...", opstr); 107 | if (Judy1Op(&PJArrayNew, PJSet1, PJSet2, operation, &JError) == JERR) 108 | printf(" failed, error %d\n", JU_ERRNO(&JError)); 109 | else 110 | { // check results 111 | for (i = 0, Index = 0L, judy_rv = 112 | Judy1First(PJArrayNew, &Index, &JError); judy_rv == 1; 113 | i++, judy_rv = Judy1Next(PJArrayNew, &Index, &JError)) 114 | { 115 | if ((i >= result_size) || (Index != result[i])) 116 | { 117 | printf("Failed\n"); 118 | return; 119 | } 120 | } 121 | if (i > result_size) 122 | printf("Failed\n"); 123 | else 124 | printf("Ok\n"); 125 | } 126 | return; 127 | } 128 | 129 | int 130 | main() 131 | { 132 | void *PJSet1 = 0; 133 | void *PJSet2 = 0; 134 | 135 | // Test Judy1Op 136 | // init PJSet1 and PJSet2 137 | PJSet1 = ularray2Judy(set1, LARRAYSIZE(set1)); 138 | PJSet2 = ularray2Judy(set2, LARRAYSIZE(set2)); 139 | 140 | testandcheck(PJSet1, PJSet2, JUDY1OP_AND, "AND", 141 | resultAND, LARRAYSIZE(resultAND)); 142 | testandcheck(PJSet1, PJSet2, JUDY1OP_OR, "OR", 143 | resultOR, LARRAYSIZE(resultOR)); 144 | testandcheck(PJSet1, PJSet2, JUDY1OP_ANDNOT, "1ANDNOT2", 145 | result1ANDNOT2, LARRAYSIZE(result1ANDNOT2)); 146 | testandcheck(PJSet2, PJSet1, JUDY1OP_ANDNOT, "2ANDNOT1", 147 | result2ANDNOT1, LARRAYSIZE(result2ANDNOT1)); 148 | 149 | return (0); 150 | } 151 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/Makefile: -------------------------------------------------------------------------------- 1 | CCFLAGS += -ggdb 2 | LIBS = -lJudy 3 | 4 | all: Judy1DupCheck Judy1OpCheck 5 | 6 | Judy1DupCheck: Judy1Dup.c Judy1DupCheck.c 7 | $(CC) $(CCFLAGS) -o $@ $^ $(LIBS) 8 | 9 | Judy1OpCheck: Judy1Op.c Judy1OpCheck.c 10 | $(CC) $(CCFLAGS) -o $@ $^ $(LIBS) 11 | 12 | clean: 13 | rm -f Judy1DupCheck Judy1OpCheck *.o 14 | -------------------------------------------------------------------------------- /judy-1.0.5/examples/README: -------------------------------------------------------------------------------- 1 | This directory contains example programs that show some of the many ways Judy 2 | can be utilized, in other words it contains useful applications of Judy. 3 | 4 | Judy1Dup: Clone (duplicate) a Judy Array. 5 | 6 | Judy1Op: Support Logical "set" operations on Judy1 arrays. 7 | 8 | See the source code for more information. 9 | -------------------------------------------------------------------------------- /judy-1.0.5/src/Judy.h.check.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 - 2002 Hewlett-Packard Company 2 | // 3 | // This program is free software; you can redistribute it and/or modify it 4 | // under the term of the GNU Lesser General Public License as published by the 5 | // Free Software Foundation; either version 2 of the License, or (at your 6 | // option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but WITHOUT 9 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | // for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public License 14 | // along with this program; if not, write to the Free Software Foundation, 15 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // _________________ 17 | 18 | // @(#) $Revision: 4.17 $ $Source: /judy/src/Judy.h.check.c $ 19 | // 20 | // Fake "program" to test the exports in Judy.h by exercising each one. This 21 | // program should compile OK (with libJudy.a) but does not run OK. 22 | 23 | #include "Judy.h" 24 | 25 | int 26 | main() 27 | { 28 | Pvoid_t PArray = (Pvoid_t) NULL; 29 | PPvoid_t PPArray = &PArray; 30 | Word_t Index = 0; 31 | PWord_t PIndex = &Index; 32 | uint8_t *CIndex = NULL; 33 | PPvoid_t PPvoid; 34 | Word_t myword; 35 | Word_t Length; 36 | int myint; 37 | 38 | // JUDY FUNCTIONS: 39 | 40 | myint = Judy1Test ( PArray, Index, PJE0); 41 | myint = Judy1Set (PPArray, Index, PJE0); 42 | myint = Judy1SetArray (PPArray, Index, &Index, PJE0); 43 | myint = Judy1Unset (PPArray, Index, PJE0); 44 | myword = Judy1Count ( PArray, Index, Index, PJE0); 45 | myint = Judy1ByCount ( PArray, Index, PIndex, PJE0); 46 | myword = Judy1FreeArray (PPArray, PJE0); 47 | myword = Judy1MemUsed ( PArray ); 48 | myword = Judy1MemActive ( PArray ); 49 | myint = Judy1First ( PArray, PIndex, PJE0); 50 | myint = Judy1Next ( PArray, PIndex, PJE0); 51 | myint = Judy1Last ( PArray, PIndex, PJE0); 52 | myint = Judy1Prev ( PArray, PIndex, PJE0); 53 | myint = Judy1FirstEmpty ( PArray, PIndex, PJE0); 54 | myint = Judy1NextEmpty ( PArray, PIndex, PJE0); 55 | myint = Judy1LastEmpty ( PArray, PIndex, PJE0); 56 | myint = Judy1PrevEmpty ( PArray, PIndex, PJE0); 57 | 58 | PPvoid = JudyLGet ( PArray, Index, PJE0); 59 | PPvoid = JudyLIns (PPArray, Index, PJE0); 60 | myint = JudyLInsArray (PPArray, Index, &Index, &Index, PJE0); 61 | myint = JudyLDel (PPArray, Index, PJE0); 62 | myword = JudyLCount ( PArray, Index, Index, PJE0); 63 | PPvoid = JudyLByCount ( PArray, Index, PIndex, PJE0); 64 | myword = JudyLFreeArray (PPArray, PJE0); 65 | myword = JudyLMemUsed ( PArray ); 66 | myword = JudyLMemActive ( PArray ); 67 | PPvoid = JudyLFirst ( PArray, PIndex, PJE0); 68 | PPvoid = JudyLNext ( PArray, PIndex, PJE0); 69 | PPvoid = JudyLLast ( PArray, PIndex, PJE0); 70 | PPvoid = JudyLPrev ( PArray, PIndex, PJE0); 71 | myint = JudyLFirstEmpty ( PArray, PIndex, PJE0); 72 | myint = JudyLNextEmpty ( PArray, PIndex, PJE0); 73 | myint = JudyLLastEmpty ( PArray, PIndex, PJE0); 74 | myint = JudyLPrevEmpty ( PArray, PIndex, PJE0); 75 | 76 | PPvoid = JudySLGet ( PArray, CIndex, PJE0); 77 | PPvoid = JudySLIns (PPArray, CIndex, PJE0); 78 | myint = JudySLDel (PPArray, CIndex, PJE0); 79 | myword = JudySLFreeArray (PPArray, PJE0); 80 | PPvoid = JudySLFirst ( PArray, CIndex, PJE0); 81 | PPvoid = JudySLNext ( PArray, CIndex, PJE0); 82 | PPvoid = JudySLLast ( PArray, CIndex, PJE0); 83 | PPvoid = JudySLPrev ( PArray, CIndex, PJE0); 84 | 85 | PPvoid = JudyHSGet ( PArray, CIndex, Length); 86 | PPvoid = JudyHSIns (PPArray, CIndex, Length, PJE0); 87 | myint = JudyHSDel (PPArray, CIndex, Length, PJE0); 88 | 89 | 90 | // MACRO EQUIVALENTS: 91 | 92 | J1T (myint, PArray, Index); 93 | J1S (myint, PArray, Index); 94 | J1SA (myint, PArray, Index, &Index); 95 | J1U (myint, PArray, Index); 96 | J1F (myint, PArray, Index); 97 | J1N (myint, PArray, Index); 98 | J1L (myint, PArray, Index); 99 | J1P (myint, PArray, Index); 100 | J1FE (myint, PArray, Index); 101 | J1NE (myint, PArray, Index); 102 | J1LE (myint, PArray, Index); 103 | J1PE (myint, PArray, Index); 104 | J1C (myword, PArray, Index, Index); 105 | J1BC (myint, PArray, Index, Index); 106 | J1FA (myword, PArray); 107 | 108 | JLG (PPvoid, PArray, Index); 109 | JLI (PPvoid, PArray, Index); 110 | JLIA (myint, PArray, Index, &Index, &Index); 111 | JLD (myint, PArray, Index); 112 | JLF (PPvoid, PArray, Index); 113 | JLN (PPvoid, PArray, Index); 114 | JLL (PPvoid, PArray, Index); 115 | JLP (PPvoid, PArray, Index); 116 | JLFE (myint, PArray, Index); 117 | JLNE (myint, PArray, Index); 118 | JLLE (myint, PArray, Index); 119 | JLPE (myint, PArray, Index); 120 | JLC (myword, PArray, Index, Index); 121 | JLBC (PPvoid, PArray, myword, Index); 122 | JLFA (myword, PArray); 123 | 124 | JSLG (PPvoid, PArray, CIndex); 125 | JSLI (PPvoid, PArray, CIndex); 126 | JSLD (myint, PArray, CIndex); 127 | JSLF (PPvoid, PArray, CIndex); 128 | JSLN (PPvoid, PArray, CIndex); 129 | JSLL (PPvoid, PArray, CIndex); 130 | JSLP (PPvoid, PArray, CIndex); 131 | JSLFA (myword, PArray); 132 | 133 | JHSI (PPvoid, PArray, CIndex, Length); 134 | JHSG (PPvoid, PArray, CIndex, Length); 135 | JHSD (myint, PArray, CIndex, Length); 136 | 137 | return(0); 138 | 139 | } // main() 140 | -------------------------------------------------------------------------------- /judy-1.0.5/src/Judy1/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I. -I.. -I../JudyCommon/ 2 | AM_CFLAGS = -DJUDY1 @WARN_CFLAGS@ 3 | 4 | noinst_LTLIBRARIES = libJudy1.la libnext.la libprev.la libcount.la libinline.la 5 | 6 | libJudy1_la_SOURCES = Judy1Test.c Judy1Tables.c Judy1Set.c Judy1SetArray.c Judy1Unset.c Judy1Cascade.c Judy1Count.c Judy1CreateBranch.c Judy1Decascade.c Judy1First.c Judy1FreeArray.c Judy1InsertBranch.c Judy1MallocIF.c Judy1MemActive.c Judy1MemUsed.c 7 | 8 | libnext_la_SOURCES = Judy1Next.c Judy1NextEmpty.c 9 | libnext_la_CFLAGS = $(AM_CFLAGS) -DJUDYNEXT 10 | 11 | libprev_la_SOURCES = Judy1Prev.c Judy1PrevEmpty.c 12 | libprev_la_CFLAGS = $(AM_CFLAGS) -DJUDYPREV 13 | 14 | libcount_la_SOURCES = Judy1ByCount.c 15 | libcount_la_CFLAGS = $(AM_CFLAGS) -DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB 16 | 17 | libinline_la_SOURCES = j__udy1Test.c 18 | libinline_la_CFLAGS = $(AM_CFLAGS) -DJUDYGETINLINE 19 | 20 | Judy1Tables.c: Judy1TablesGen.c 21 | $(CC) $(INCLUDES) $(AM_CFLAGS) @CFLAGS@ -o Judy1TablesGen Judy1TablesGen.c; ./Judy1TablesGen 22 | 23 | Judy1ByCount.c:../JudyCommon/JudyByCount.c 24 | cp -f ../JudyCommon/JudyByCount.c Judy1ByCount.c 25 | 26 | Judy1Cascade.c:../JudyCommon/JudyCascade.c 27 | cp -f ../JudyCommon/JudyCascade.c Judy1Cascade.c 28 | 29 | Judy1Count.c:../JudyCommon/JudyCount.c 30 | cp -f ../JudyCommon/JudyCount.c Judy1Count.c 31 | 32 | Judy1CreateBranch.c:../JudyCommon/JudyCreateBranch.c 33 | cp -f ../JudyCommon/JudyCreateBranch.c Judy1CreateBranch.c 34 | 35 | Judy1Decascade.c:../JudyCommon/JudyDecascade.c 36 | cp -f ../JudyCommon/JudyDecascade.c Judy1Decascade.c 37 | 38 | Judy1Unset.c:../JudyCommon/JudyDel.c 39 | cp -f ../JudyCommon/JudyDel.c Judy1Unset.c 40 | 41 | Judy1First.c:../JudyCommon/JudyFirst.c 42 | cp -f ../JudyCommon/JudyFirst.c Judy1First.c 43 | 44 | Judy1FreeArray.c:../JudyCommon/JudyFreeArray.c 45 | cp -f ../JudyCommon/JudyFreeArray.c Judy1FreeArray.c 46 | 47 | Judy1Test.c:../JudyCommon/JudyGet.c 48 | cp -f ../JudyCommon/JudyGet.c Judy1Test.c 49 | 50 | j__udy1Test.c:../JudyCommon/JudyGet.c 51 | cp -f ../JudyCommon/JudyGet.c j__udy1Test.c 52 | 53 | Judy1SetArray.c:../JudyCommon/JudyInsArray.c 54 | cp -f ../JudyCommon/JudyInsArray.c Judy1SetArray.c 55 | 56 | Judy1Set.c:../JudyCommon/JudyIns.c 57 | cp -f ../JudyCommon/JudyIns.c Judy1Set.c 58 | 59 | Judy1InsertBranch.c:../JudyCommon/JudyInsertBranch.c 60 | cp -f ../JudyCommon/JudyInsertBranch.c Judy1InsertBranch.c 61 | 62 | Judy1MallocIF.c:../JudyCommon/JudyMallocIF.c 63 | cp -f ../JudyCommon/JudyMallocIF.c Judy1MallocIF.c 64 | 65 | Judy1MemActive.c:../JudyCommon/JudyMemActive.c 66 | cp -f ../JudyCommon/JudyMemActive.c Judy1MemActive.c 67 | 68 | Judy1MemUsed.c:../JudyCommon/JudyMemUsed.c 69 | cp -f ../JudyCommon/JudyMemUsed.c Judy1MemUsed.c 70 | 71 | Judy1Next.c:../JudyCommon/JudyPrevNext.c 72 | cp -f ../JudyCommon/JudyPrevNext.c Judy1Next.c 73 | 74 | Judy1Prev.c:../JudyCommon/JudyPrevNext.c 75 | cp -f ../JudyCommon/JudyPrevNext.c Judy1Prev.c 76 | 77 | Judy1NextEmpty.c:../JudyCommon/JudyPrevNextEmpty.c 78 | cp -f ../JudyCommon/JudyPrevNextEmpty.c Judy1NextEmpty.c 79 | 80 | Judy1PrevEmpty.c:../JudyCommon/JudyPrevNextEmpty.c 81 | cp -f ../JudyCommon/JudyPrevNextEmpty.c Judy1PrevEmpty.c 82 | 83 | Judy1TablesGen.c:../JudyCommon/JudyTables.c 84 | cp -f ../JudyCommon/JudyTables.c Judy1TablesGen.c 85 | 86 | DISTCLEANFILES = .deps Makefile 87 | 88 | CLEANFILES = Judy1ByCount.c \ 89 | Judy1Cascade.c \ 90 | Judy1Count.c \ 91 | Judy1CreateBranch.c \ 92 | Judy1Decascade.c \ 93 | Judy1Unset.c \ 94 | Judy1First.c \ 95 | Judy1FreeArray.c \ 96 | Judy1Test.c \ 97 | j__udy1Test.c \ 98 | Judy1SetArray.c \ 99 | Judy1Set.c \ 100 | Judy1InsertBranch.c \ 101 | Judy1MallocIF.c \ 102 | Judy1MemActive.c \ 103 | Judy1MemUsed.c \ 104 | Judy1Next.c \ 105 | Judy1Prev.c \ 106 | Judy1NextEmpty.c \ 107 | Judy1PrevEmpty.c \ 108 | Judy1TablesGen.c \ 109 | Judy1Tables.c \ 110 | .libs \ 111 | Judy1TablesGen \ 112 | *.o \ 113 | *.lo \ 114 | *.la 115 | -------------------------------------------------------------------------------- /judy-1.0.5/src/Judy1/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.22 $ $Source: /judy/src/Judy1/README $ 2 | 3 | # This tree contains sources for the Judy1*() functions. 4 | # 5 | # Note: At one time, all of the Judy sources were split between Judy1/ and 6 | # JudyL/ variants, but now most of them are merged in JudyCommon/ and this 7 | # directory is vestigal. 8 | 9 | Judy1.h header for following functions 10 | 11 | lint.waivers see usage in makefile 12 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyCommon/JudyInsertBranch.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 - 2002 Hewlett-Packard Company 2 | // 3 | // This program is free software; you can redistribute it and/or modify it 4 | // under the term of the GNU Lesser General Public License as published by the 5 | // Free Software Foundation; either version 2 of the License, or (at your 6 | // option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but WITHOUT 9 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | // for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public License 14 | // along with this program; if not, write to the Free Software Foundation, 15 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // _________________ 17 | 18 | // @(#) $Revision: 4.17 $ $Source: /judy/src/JudyCommon/JudyInsertBranch.c $ 19 | 20 | // BranchL insertion functions for Judy1 and JudyL. 21 | // Compile with one of -DJUDY1 or -DJUDYL. 22 | 23 | #if (! (defined(JUDY1) || defined(JUDYL))) 24 | #error: One of -DJUDY1 or -DJUDYL must be specified. 25 | #endif 26 | 27 | #ifdef JUDY1 28 | #include "Judy1.h" 29 | #else 30 | #include "JudyL.h" 31 | #endif 32 | 33 | #include "JudyPrivate1L.h" 34 | 35 | extern int j__udyCreateBranchL(Pjp_t, Pjp_t, uint8_t *, Word_t, Pvoid_t); 36 | 37 | 38 | // **************************************************************************** 39 | // __ J U D Y I N S E R T B R A N C H 40 | // 41 | // Insert 2-element BranchL in between Pjp and Pjp->jp_Addr. 42 | // 43 | // Return -1 if out of memory, otherwise return 1. 44 | 45 | FUNCTION int j__udyInsertBranch( 46 | Pjp_t Pjp, // JP containing narrow pointer. 47 | Word_t Index, // outlier to Pjp. 48 | Word_t BranchLevel, // of what JP points to, mapped from JP type. 49 | Pjpm_t Pjpm) // for global accounting. 50 | { 51 | jp_t JP2 [2]; 52 | jp_t JP; 53 | Pjp_t PjpNull; 54 | Word_t XorExp; 55 | Word_t Inew, Iold; 56 | Word_t DCDMask; // initially for original BranchLevel. 57 | int Ret; 58 | uint8_t Exp2[2]; 59 | uint8_t DecodeByteN, DecodeByteO; 60 | 61 | // Get the current mask for the DCD digits: 62 | 63 | DCDMask = cJU_DCDMASK(BranchLevel); 64 | 65 | // Obtain Dcd bits that differ between Index and JP, shifted so the 66 | // digit for BranchLevel is the LSB: 67 | 68 | XorExp = ((Index ^ JU_JPDCDPOP0(Pjp)) & (cJU_ALLONES >> cJU_BITSPERBYTE)) 69 | >> (BranchLevel * cJU_BITSPERBYTE); 70 | assert(XorExp); // Index must be an outlier. 71 | 72 | // Count levels between object under narrow pointer and the level at which 73 | // the outlier diverges from it, which is always at least initial 74 | // BranchLevel + 1, to end up with the level (JP type) at which to insert 75 | // the new intervening BranchL: 76 | 77 | do { ++BranchLevel; } while ((XorExp >>= cJU_BITSPERBYTE)); 78 | assert((BranchLevel > 1) && (BranchLevel < cJU_ROOTSTATE)); 79 | 80 | // Get the MSB (highest digit) that differs between the old expanse and 81 | // the new Index to insert: 82 | 83 | DecodeByteO = JU_DIGITATSTATE(JU_JPDCDPOP0(Pjp), BranchLevel); 84 | DecodeByteN = JU_DIGITATSTATE(Index, BranchLevel); 85 | 86 | assert(DecodeByteO != DecodeByteN); 87 | 88 | // Determine sorted order for old expanse and new Index digits: 89 | 90 | if (DecodeByteN > DecodeByteO) { Iold = 0; Inew = 1; } 91 | else { Iold = 1; Inew = 0; } 92 | 93 | // Copy old JP into staging area for new Branch 94 | JP2 [Iold] = *Pjp; 95 | Exp2[Iold] = DecodeByteO; 96 | Exp2[Inew] = DecodeByteN; 97 | 98 | // Create a 2 Expanse Linear branch 99 | // 100 | // Note: Pjp->jp_Addr is set by j__udyCreateBranchL() 101 | 102 | Ret = j__udyCreateBranchL(Pjp, JP2, Exp2, 2, Pjpm); 103 | if (Ret == -1) return(-1); 104 | 105 | // Get Pjp to the NULL of where to do insert 106 | PjpNull = ((P_JBL(Pjp->jp_Addr))->jbl_jp) + Inew; 107 | 108 | // Convert to a cJU_JPIMMED_*_01 at the correct level: 109 | // Build JP and set type below to: cJU_JPIMMED_X_01 110 | JU_JPSETADT(PjpNull, 0, Index, cJU_JPIMMED_1_01 - 2 + BranchLevel); 111 | 112 | // Return pointer to Value area in cJU_JPIMMED_X_01 113 | JUDYLCODE(Pjpm->jpm_PValue = (Pjv_t) PjpNull;) 114 | 115 | // The old JP now points to a BranchL that is at higher level. Therefore 116 | // it contains excess DCD bits (in the least significant position) that 117 | // must be removed (zeroed); that is, they become part of the Pop0 118 | // subfield. Note that the remaining (lower) bytes in the Pop0 field do 119 | // not change. 120 | // 121 | // Take from the old DCDMask, which went "down" to a lower BranchLevel, 122 | // and zero any high bits that are still in the mask at the new, higher 123 | // BranchLevel; then use this mask to zero the bits in jp_DcdPopO: 124 | 125 | // Set old JP to a BranchL at correct level 126 | 127 | Pjp->jp_Type = cJU_JPBRANCH_L2 - 2 + BranchLevel; 128 | DCDMask ^= cJU_DCDMASK(BranchLevel); 129 | DCDMask = ~DCDMask & JU_JPDCDPOP0(Pjp); 130 | JP = *Pjp; 131 | JU_JPSETADT(Pjp, JP.jp_Addr, DCDMask, JP.jp_Type); 132 | 133 | return(1); 134 | 135 | } // j__udyInsertBranch() 136 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyCommon/JudyMalloc.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 - 2002 Hewlett-Packard Company 2 | // 3 | // This program is free software; you can redistribute it and/or modify it 4 | // under the term of the GNU Lesser General Public License as published by the 5 | // Free Software Foundation; either version 2 of the License, or (at your 6 | // option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but WITHOUT 9 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | // for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public License 14 | // along with this program; if not, write to the Free Software Foundation, 15 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // _________________ 17 | 18 | // @(#) $Revision: 4.33 $ $Source: /judy/src/JudyCommon/JudyMalloc.c $ 19 | // ************************************************************************ // 20 | // JUDY - Memory Allocater // 21 | // -by- // 22 | // Douglas L. Baskins // 23 | // Hewlett Packard // 24 | // Fort Collins, Co // 25 | // (970) 229-2027 // 26 | // // 27 | // ************************************************************************ // 28 | 29 | // JUDY INCLUDE FILES 30 | #include "Judy.h" 31 | 32 | // **************************************************************************** 33 | // J U D Y M A L L O C 34 | // 35 | // Allocate RAM. This is the single location in Judy code that calls 36 | // malloc(3C). Note: JPM accounting occurs at a higher level. 37 | 38 | Word_t JudyMalloc( 39 | Word_t Words) 40 | { 41 | Word_t Addr; 42 | 43 | Addr = (Word_t) malloc(Words * sizeof(Word_t)); 44 | return(Addr); 45 | 46 | } // JudyMalloc() 47 | 48 | 49 | // **************************************************************************** 50 | // J U D Y F R E E 51 | 52 | void JudyFree( 53 | void * PWord, 54 | Word_t Words) 55 | { 56 | (void) Words; 57 | free(PWord); 58 | 59 | } // JudyFree() 60 | 61 | 62 | // **************************************************************************** 63 | // J U D Y M A L L O C 64 | // 65 | // Higher-level "wrapper" for allocating objects that need not be in RAM, 66 | // although at this time they are in fact only in RAM. Later we hope that some 67 | // entire subtrees (at a JPM or branch) can be "virtual", so their allocations 68 | // and frees should go through this level. 69 | 70 | Word_t JudyMallocVirtual( 71 | Word_t Words) 72 | { 73 | return(JudyMalloc(Words)); 74 | 75 | } // JudyMallocVirtual() 76 | 77 | 78 | // **************************************************************************** 79 | // J U D Y F R E E 80 | 81 | void JudyFreeVirtual( 82 | void * PWord, 83 | Word_t Words) 84 | { 85 | JudyFree(PWord, Words); 86 | 87 | } // JudyFreeVirtual() 88 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyCommon/JudyMemUsed.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 - 2002 Hewlett-Packard Company 2 | // 3 | // This program is free software; you can redistribute it and/or modify it 4 | // under the term of the GNU Lesser General Public License as published by the 5 | // Free Software Foundation; either version 2 of the License, or (at your 6 | // option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but WITHOUT 9 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | // for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public License 14 | // along with this program; if not, write to the Free Software Foundation, 15 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // _________________ 17 | 18 | // @(#) $Revision: 4.5 $ $Source: /judy/src/JudyCommon/JudyMemUsed.c $ 19 | // 20 | // Return number of bytes of memory used to support a Judy1/L array. 21 | // Compile with one of -DJUDY1 or -DJUDYL. 22 | 23 | #if (! (defined(JUDY1) || defined(JUDYL))) 24 | #error: One of -DJUDY1 or -DJUDYL must be specified. 25 | #endif 26 | 27 | #ifdef JUDY1 28 | #include "Judy1.h" 29 | #else 30 | #include "JudyL.h" 31 | #endif 32 | 33 | #include "JudyPrivate1L.h" 34 | 35 | #ifdef JUDY1 36 | FUNCTION Word_t Judy1MemUsed 37 | #else // JUDYL 38 | FUNCTION Word_t JudyLMemUsed 39 | #endif 40 | ( 41 | Pcvoid_t PArray // from which to retrieve. 42 | ) 43 | { 44 | Word_t Words = 0; 45 | 46 | if (PArray == (Pcvoid_t) NULL) return(0); 47 | 48 | if (JU_LEAFW_POP0(PArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW 49 | { 50 | Pjlw_t Pjlw = P_JLW(PArray); // first word of leaf. 51 | Words = JU_LEAFWPOPTOWORDS(Pjlw[0] + 1); // based on pop1. 52 | } 53 | else 54 | { 55 | Pjpm_t Pjpm = P_JPM(PArray); 56 | Words = Pjpm->jpm_TotalMemWords; 57 | } 58 | 59 | return(Words * sizeof(Word_t)); // convert to bytes. 60 | 61 | } // Judy1MemUsed() / JudyLMemUsed() 62 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyCommon/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I. -I.. 2 | AM_CFLAGS = @CFLAGS@ @WARN_CFLAGS@ 3 | 4 | noinst_LTLIBRARIES = libJudyMalloc.la 5 | 6 | libJudyMalloc_la_SOURCES = JudyMalloc.c 7 | 8 | DISTCLEANFILES = .deps Makefile 9 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyCommon/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.24 $ $Source: /judy/src/JudyCommon/README $ 2 | # 3 | # This tree contains sources for Judy common files. These include shared 4 | # header files, ifdef'd common source files for Judy1/JudyL functions, and 5 | # shared utility functions. 6 | 7 | 8 | # SHARED HEADER FILES: 9 | 10 | JudyPrivate.h global private header file for all Judy internal 11 | sources 12 | 13 | JudyPrivateBranch.h global private header file for all Judy internal 14 | sources, specifically for branch-related 15 | declarations 16 | 17 | JudyPrivate1L.h global private header file for Judy internal 18 | sources that generate both Judy1 and JudyL 19 | object files, via -DJUDY1 or -DJUDYL, using 20 | common names for JP Types, plus some other 21 | generic declarations too 22 | 23 | 24 | # IFDEF'D COMMON SOURCE FILES FOR JUDY1/JUDYL FUNCTIONS: 25 | # 26 | # See Judy(3C) manual entry about these sources for exported functions. 27 | 28 | JudyGet.c common code for Judy1Test() and JudyLGet() 29 | JudyIns.c common code for Judy1Set() and JudyLIns() 30 | JudyDel.c common code for Judy1Unset() and JudyLDel() 31 | JudyFirst.c common code for Judy1 and JudyL 32 | JudyPrevNext.c common code for Judy1, JudyL; Judy*Prev(), Judy*Next() 33 | JudyPrevNextEmpty.c common code for Judy1, JudyL; Judy*PrevEmpty(), 34 | Judy*NextEmpty() 35 | JudyCount.c common code for Judy1 and JudyL 36 | JudyByCount.c common code for Judy1 and JudyL 37 | JudyFreeArray.c common code for Judy1 and JudyL 38 | JudyMemUsed.c common code for Judy1 and JudyL 39 | JudyMemActive.c common code for Judy1 and JudyL 40 | 41 | JudyInsArray.c common code for Judy1 and JudyL 42 | 43 | 44 | # SHARED UTILITY FUNCTIONS: 45 | 46 | JudyMalloc.c source file 47 | 48 | JudyTables.c static definitions of translation tables; a main 49 | program is #ifdef-embedded to generate these tables 50 | 51 | # Common code for Judy1 and JudyL that is compiled twice with -DJUDY1 or 52 | # -DJUDYL: 53 | 54 | JudyInsertBranch.c insert a linear branch between a branch and a leaf 55 | JudyCreateBranch.c create and copy all types of branches 56 | 57 | JudyCascade.c handles overflow insertion of an Index, including 58 | common Decode bytes and branch creation 59 | 60 | JudyDecascade.c handles underflow deletion of an Index, including 61 | common Decode bytes and branch deletion 62 | 63 | JudyMallocIF.c a Judy malloc/free interface, for statistics and 64 | debugging 65 | 66 | JudyPrintJP.c debug/trace code #included in other *.c files 67 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyHS/JudyHS.h: -------------------------------------------------------------------------------- 1 | // **************************************************************************** 2 | // Quick and dirty header file for use with old Judy.h without JudyHS defs 3 | // May 2004 (dlb) - No copyright or license -- it is free period. 4 | 5 | #include 6 | 7 | // **************************************************************************** 8 | // JUDYHSL MACROS: 9 | 10 | #define JHSI(PV, PArray, PIndex, Count) \ 11 | J_2P(PV, (&(PArray)), PIndex, Count, JudyHSIns, "JudyHSIns") 12 | #define JHSG(PV, PArray, PIndex, Count) \ 13 | (PV) = (Pvoid_t) JudyHSGet(PArray, PIndex, Count) 14 | #define JHSD(Rc, PArray, PIndex, Count) \ 15 | J_2I(Rc, (&(PArray)), PIndex, Count, JudyHSDel, "JudyHSDel") 16 | #define JHSFA(Rc, PArray) \ 17 | J_0I(Rc, (&(PArray)), JudyHSFreeArray, "JudyHSFreeArray") 18 | 19 | // **************************************************************************** 20 | // JUDY memory interface to malloc() FUNCTIONS: 21 | 22 | extern Word_t JudyMalloc(Word_t); // words reqd => words allocd. 23 | extern Word_t JudyMallocVirtual(Word_t); // words reqd => words allocd. 24 | extern void JudyFree(Pvoid_t, Word_t); // block to free and its size in words. 25 | extern void JudyFreeVirtual(Pvoid_t, Word_t); // block to free and its size in words. 26 | 27 | // **************************************************************************** 28 | // JUDYHS FUNCTIONS: 29 | 30 | extern PPvoid_t JudyHSGet( Pcvoid_t, void *, Word_t); 31 | extern PPvoid_t JudyHSIns( PPvoid_t, void *, Word_t, P_JE); 32 | extern int JudyHSDel( PPvoid_t, void *, Word_t, P_JE); 33 | extern Word_t JudyHSFreeArray( PPvoid_t, P_JE); 34 | 35 | extern uint32_t JudyHashStr( void *, Word_t); 36 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyHS/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I. -I.. -I../JudyCommon/ 2 | AM_CFLAGS = @CFLAGS@ @WARN_CFLAGS@ 3 | 4 | noinst_LTLIBRARIES = libJudyHS.la 5 | 6 | libJudyHS_la_SOURCES = JudyHS.c 7 | 8 | DISTCLEANFILES = .deps Makefile 9 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyHS/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.22 $ $Source: /judy/src/JudyHS/README $ 2 | 3 | # This tree contains sources for the JudyHS*() functions. 4 | # 5 | # Note: At one time, all of the Judy sources were split between Judy1/ and 6 | # JudyL/ variants, but now most of them are merged in JudyCommon/ and this 7 | # directory is vestigal. 8 | 9 | JudyHS.h header for using JudyHS.c with older versions of Judy.h 10 | JudyHS.c source of JudyHS functions 11 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyL/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I. -I.. -I../JudyCommon/ 2 | AM_CFLAGS = -DJUDYL @WARN_CFLAGS@ 3 | 4 | noinst_LTLIBRARIES = libJudyL.la libnext.la libprev.la libcount.la libinline.la 5 | 6 | libJudyL_la_SOURCES = JudyLCascade.c JudyLTables.c JudyLCount.c JudyLCreateBranch.c JudyLDecascade.c JudyLDel.c JudyLFirst.c JudyLFreeArray.c JudyLGet.c JudyLInsArray.c JudyLIns.c JudyLInsertBranch.c JudyLMallocIF.c JudyLMemActive.c JudyLMemUsed.c 7 | 8 | libnext_la_SOURCES = JudyLNext.c JudyLNextEmpty.c 9 | libnext_la_CFLAGS = $(AM_CFLAGS) -DJUDYNEXT 10 | 11 | libprev_la_SOURCES = JudyLPrev.c JudyLPrevEmpty.c 12 | libprev_la_CFLAGS = $(AM_CFLAGS) -DJUDYPREV 13 | 14 | libcount_la_SOURCES = JudyLByCount.c 15 | libcount_la_CFLAGS = $(AM_CFLAGS) -DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB 16 | 17 | libinline_la_SOURCES = j__udyLGet.c 18 | libinline_la_CFLAGS = $(AM_CFLAGS) -DJUDYGETINLINE 19 | 20 | JudyLTables.c: JudyLTablesGen.c 21 | $(CC) $(INCLUDES) $(AM_CFLAGS) @CFLAGS@ -o JudyLTablesGen JudyLTablesGen.c; ./JudyLTablesGen 22 | 23 | JudyLByCount.c: ../JudyCommon/JudyByCount.c 24 | cp -f ../JudyCommon/JudyByCount.c JudyLByCount.c 25 | 26 | JudyLCascade.c:../JudyCommon/JudyCascade.c 27 | cp -f ../JudyCommon/JudyCascade.c JudyLCascade.c 28 | 29 | JudyLCount.c:../JudyCommon/JudyCount.c 30 | cp -f ../JudyCommon/JudyCount.c JudyLCount.c 31 | 32 | JudyLCreateBranch.c:../JudyCommon/JudyCreateBranch.c 33 | cp -f ../JudyCommon/JudyCreateBranch.c JudyLCreateBranch.c 34 | 35 | JudyLDecascade.c:../JudyCommon/JudyDecascade.c 36 | cp -f ../JudyCommon/JudyDecascade.c JudyLDecascade.c 37 | 38 | JudyLDel.c:../JudyCommon/JudyDel.c 39 | cp -f ../JudyCommon/JudyDel.c JudyLDel.c 40 | 41 | JudyLFirst.c:../JudyCommon/JudyFirst.c 42 | cp -f ../JudyCommon/JudyFirst.c JudyLFirst.c 43 | 44 | JudyLFreeArray.c:../JudyCommon/JudyFreeArray.c 45 | cp -f ../JudyCommon/JudyFreeArray.c JudyLFreeArray.c 46 | 47 | JudyLGet.c:../JudyCommon/JudyGet.c 48 | cp -f ../JudyCommon/JudyGet.c JudyLGet.c 49 | 50 | j__udyLGet.c:../JudyCommon/JudyGet.c 51 | cp -f ../JudyCommon/JudyGet.c j__udyLGet.c 52 | 53 | JudyLInsArray.c:../JudyCommon/JudyInsArray.c 54 | cp -f ../JudyCommon/JudyInsArray.c JudyLInsArray.c 55 | 56 | JudyLIns.c:../JudyCommon/JudyIns.c 57 | cp -f ../JudyCommon/JudyIns.c JudyLIns.c 58 | 59 | JudyLInsertBranch.c:../JudyCommon/JudyInsertBranch.c 60 | cp -f ../JudyCommon/JudyInsertBranch.c JudyLInsertBranch.c 61 | 62 | JudyLMallocIF.c:../JudyCommon/JudyMallocIF.c 63 | cp -f ../JudyCommon/JudyMallocIF.c JudyLMallocIF.c 64 | 65 | JudyLMemActive.c:../JudyCommon/JudyMemActive.c 66 | cp -f ../JudyCommon/JudyMemActive.c JudyLMemActive.c 67 | 68 | JudyLMemUsed.c:../JudyCommon/JudyMemUsed.c 69 | cp -f ../JudyCommon/JudyMemUsed.c JudyLMemUsed.c 70 | 71 | JudyLNext.c:../JudyCommon/JudyPrevNext.c 72 | cp -f ../JudyCommon/JudyPrevNext.c JudyLNext.c 73 | 74 | JudyLPrev.c:../JudyCommon/JudyPrevNext.c 75 | cp -f ../JudyCommon/JudyPrevNext.c JudyLPrev.c 76 | 77 | JudyLNextEmpty.c:../JudyCommon/JudyPrevNextEmpty.c 78 | cp -f ../JudyCommon/JudyPrevNextEmpty.c JudyLNextEmpty.c 79 | 80 | JudyLPrevEmpty.c:../JudyCommon/JudyPrevNextEmpty.c 81 | cp -f ../JudyCommon/JudyPrevNextEmpty.c JudyLPrevEmpty.c 82 | 83 | JudyLTablesGen.c:../JudyCommon/JudyTables.c 84 | cp -f ../JudyCommon/JudyTables.c JudyLTablesGen.c 85 | 86 | DISTCLEANFILES = .deps Makefile 87 | 88 | CLEANFILES = JudyLByCount.c \ 89 | JudyLCascade.c \ 90 | JudyLCount.c \ 91 | JudyLCreateBranch.c \ 92 | JudyLDecascade.c \ 93 | JudyLDel.c \ 94 | JudyLFirst.c \ 95 | JudyLFreeArray.c \ 96 | JudyLGet.c \ 97 | j__udyLGet.c \ 98 | JudyLInsArray.c \ 99 | JudyLIns.c \ 100 | JudyLInsertBranch.c \ 101 | JudyLMallocIF.c \ 102 | JudyLMemActive.c \ 103 | JudyLMemUsed.c \ 104 | JudyLNext.c \ 105 | JudyLPrev.c \ 106 | JudyLNextEmpty.c \ 107 | JudyLPrevEmpty.c \ 108 | JudyLTablesGen.c \ 109 | JudyLTables.c \ 110 | JudyLTablesGen \ 111 | .libs \ 112 | *.o \ 113 | *.lo \ 114 | *.la 115 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudyL/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.19 $ $Source: /judy/src/JudyL/README $ 2 | # 3 | # This tree contains sources for the JudyL*() functions. 4 | # 5 | 6 | JudyL.h 7 | 8 | lint.waivers see usage in makefile 9 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudySL/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I. -I.. -I../JudyCommon/ 2 | AM_CFLAGS = @CFLAGS@ @WARN_CFLAGS@ 3 | 4 | noinst_LTLIBRARIES = libJudySL.la 5 | 6 | libJudySL_la_SOURCES = JudySL.c 7 | 8 | DISTCLEANFILES = .deps Makefile 9 | -------------------------------------------------------------------------------- /judy-1.0.5/src/JudySL/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.3 $ $Source: /judy/src/JudySL/README $ 2 | # 3 | # This tree contains sources for the JudySL*() functions. 4 | 5 | JudySL.c source file 6 | Note: JudySL.h is no longer needed (May 2004) 7 | -------------------------------------------------------------------------------- /judy-1.0.5/src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = . JudyCommon JudyL Judy1 JudySL JudyHS obj 2 | 3 | DISTCLEANFILES = .deps Makefile 4 | -------------------------------------------------------------------------------- /judy-1.0.5/src/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.10 $ $Source: /judy/src/README $ 2 | 3 | # This tree contains sources for the Judy project. 4 | 5 | # For more on how to build Judy files, see make_includes/README. 6 | 7 | The 'sh_build' script to compiling Judy manually for other platforms 8 | 9 | # Current stuff: 10 | 11 | Judy.h exported header file for libJudy.a 12 | Judy.h.check.c test program for Judy.h 13 | 14 | JudyCommon/ shared utility functions and common source files 15 | Judy1/ Judy1.h 16 | JudyL/ JudyL.h 17 | JudySL/ JudySL*() 18 | JudyHS/ JudyHS*() 19 | 20 | apps/ applications done or redone using Judy 21 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.4 $ $Source: /judy/src/apps/README $ 2 | # 3 | # This tree contains sources for Judy-related applications, that is, for 4 | # sources including a main() function, suitable for building an executable 5 | # program. Some of these sources are packaged and delivered to Judy users 6 | # as an optional package of example sources. 7 | 8 | benchmark/ sources for benchmarking programs, that is, demos that 9 | yield performance metrics; including sources for metrics 10 | displayed on the Judy website 11 | 12 | demo/ sources for programs that demonstrate the use of Judy 13 | but are probably not useful as templates for writing 14 | Judy-based applications 15 | 16 | # misc/ other sources; none exist at this time; and as they come 17 | along, they might go in misc/ or in other, more-specific 18 | directories 19 | 20 | noship/ other example sources we are not free to deliver to Judy 21 | users, or which it's inappropriate or premature to deliver 22 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/JudySort.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | // By Doug Baskins Aug 2002 - for JudySL man page 8 | 9 | int // Usage: JudySort < file_to_sort 10 | main() 11 | { 12 | Pvoid_t PJArray = (PWord_t)NULL; // Judy array. 13 | PWord_t PValue; // Judy array element. 14 | Word_t Bytes; // size of JudySL array. 15 | char Index[BUFSIZ]; // string to sort. 16 | 17 | while (fgets(Index, sizeof(Index), stdin) != (char *)NULL) 18 | { 19 | JSLI(PValue, PJArray, Index); // store string into array 20 | ++(*PValue); // count instances of string 21 | } 22 | Index[0] = '\0'; // start with smallest string. 23 | JSLF(PValue, PJArray, Index); // get first string 24 | while (PValue != NULL) 25 | { 26 | while ((*PValue)--) // print duplicates 27 | printf("%s", Index); 28 | JSLN(PValue, PJArray, Index); // get next string 29 | } 30 | JSLFA(Bytes, PJArray); // free array 31 | 32 | fprintf(stderr, "The JudySL array used %lu bytes of memory\n", Bytes); 33 | return (0); 34 | } 35 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/Makefile_deliver: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.11 $ $Source: /judy/src/apps/demo/Makefile_deliver $ 2 | 3 | # Makefile for Judy demo programs. 4 | 5 | # Locations of Judy header file and library; correct if necessary: 6 | # 7 | # Note the use of the archive version (libJudy.a) for speed, although the 8 | # difference from shared libs is not great on Linux. 9 | 10 | JUDY = /usr 11 | 12 | JUDY_INCDIR = $(JUDY)/include 13 | JUDY_LIBDIR = $(JUDY)/lib 14 | JUDY_HEADER = $(JUDY_INCDIR)/Judy.h 15 | JUDY_LIBBASE = Judy 16 | JUDY_LIB = $(JUDY_LIBDIR)/lib$(JUDY_LIBBASE).a 17 | 18 | DEBUG = -O 19 | CFLAGS = $(DEBUG) 20 | CC = cc 21 | 22 | # Place files locally by default: 23 | 24 | OBJS = interL.o interSL.o funhist.o JudySort.o 25 | EXECS = interL interSL funhist JudySort 26 | 27 | # === RULES === 28 | 29 | all: $(EXECS) 30 | debug:; make -f Makefile DEBUG='-g' 31 | 32 | # Unfortunately not all make programs understand filename generation via $(@F), 33 | # or at least $$(@F) on a dependencies line, so spell out each $EXECS target 34 | # separately: 35 | 36 | interL: interL.c $(JUDY_HEADER) $(JUDY_LIB) 37 | $(CC) $(CFLAGS) -I $(JUDY_INCDIR) $(@F).c \ 38 | -L$(JUDY_LIBDIR) -l$(JUDY_LIBBASE) -o $@ 39 | 40 | interSL: interSL.c $(JUDY_HEADER) $(JUDY_LIB) 41 | $(CC) $(CFLAGS) -I $(JUDY_INCDIR) $(@F).c \ 42 | -L$(JUDY_LIBDIR) -l$(JUDY_LIBBASE) -o $@ 43 | 44 | funhist: funhist.c $(JUDY_HEADER) $(JUDY_LIB) 45 | $(CC) $(CFLAGS) -I $(JUDY_INCDIR) $(@F).c \ 46 | -L$(JUDY_LIBDIR) -l$(JUDY_LIBBASE) -o $@ 47 | 48 | JudySort: JudySort.c $(JUDY_HEADER) $(JUDY_LIB) 49 | $(CC) $(CFLAGS) -I $(JUDY_INCDIR) $(@F).c \ 50 | -L$(JUDY_LIBDIR) -l$(JUDY_LIBBASE) -o $@ 51 | 52 | clean:; rm -rf core $(OBJS) $(EXECS) 53 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/README: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.8 $ $Source: /judy/src/apps/demo/README $ 2 | 3 | # Demo programs to be included with the Judy distribution. 4 | 5 | README_deliver delivered with files from this directory, renamed to "README" 6 | 7 | run_demo simple Judy example script; explains, shows source code, 8 | compiles and runs it 9 | 10 | Makefile_deliver 11 | delivered as "Makefile"; by default, makes all the demo 12 | programs; the libJudy.a and Judy.h locations might have 13 | to be changed (via cc -I options) 14 | NOTE: This file contains "#ifdef" directives that look 15 | to make like comments, but don't expect the makefile to 16 | run prior to unifdef'ing in the makefile. That is, use 17 | the constructed version for a given platform. 18 | 19 | funhist.c function histogram program 20 | 21 | interL.c interactive JudyL program 22 | interSL.c interactive JudySL program 23 | 24 | JudySort.c JudySL version of "sort -u" 25 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/README_deliver: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.5 $ $Source: /judy/src/apps/demo/README_deliver $ 2 | 3 | # Demo programs to be included with the Judy distribution. 4 | 5 | run_demo Simple Judy example script; explains, shows source code, 6 | compiles and runs it. 7 | 8 | Makefile By default, makes all the demo programs. The libJudy.a 9 | and Judy.h locations might have to be changed (via cc -I 10 | options). 11 | 12 | funhist.c Function histogram program. 13 | 14 | interL.c Interactive JudyL program. 15 | interSL.c Interactive JudySL program. 16 | 17 | JudySort.c JudySL version of "sort -u". 18 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/interL.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | main() // Simple JudyL demo, see "run_demo" script; @(#) $Revision: 4.4 $ 5 | { 6 | Pvoid_t Parray = (Pvoid_t) NULL; // empty JudyL array. 7 | Word_t * Pvalue; // value for one index. 8 | char line[BUFSIZ]; // input line. 9 | Word_t index; // in JudyL array. 10 | 11 | printf("Interactive Judy demo program to input, sort, and list numbers.\n" 12 | "Enter a number: "); // fflush(stdout); ? 13 | 14 | while (fgets(line, BUFSIZ, stdin)) // input. 15 | { 16 | index = strtoul(line, NULL, 0); // note: bad input => 0. 17 | JLI(Pvalue, Parray, index); // insert index in JudyL array. 18 | ++(*Pvalue); // count duplicates. 19 | 20 | printf(" Index Dups\n"); // print all saved indexes: 21 | index = 0; // start search at zero. 22 | JLF(Pvalue, Parray, index); // find first saved index. 23 | 24 | while (Pvalue != NULL) 25 | { 26 | printf("%12lu %5lu\n", index, *Pvalue); 27 | JLN(Pvalue, Parray, index); // find next saved index. 28 | } 29 | printf("Next: "); // fflush(stdout); ? 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/interSL.c: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2000 - 2002 Hewlett-Packard Company 2 | // 3 | // This program is free software; you can redistribute it and/or modify it 4 | // under the term of the GNU Lesser General Public License as published by the 5 | // Free Software Foundation; either version 2 of the License, or (at your 6 | // option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, but WITHOUT 9 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 | // for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public License 14 | // along with this program; if not, write to the Free Software Foundation, 15 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // _________________ 17 | 18 | // @(#) $Revision: 4.5 $ $Source: /judy/src/apps/demo/interSL.c $ 19 | // 20 | // INTERACTIVE JUDYSL DEMO PROGRAM 21 | // 22 | // This program is a very simple interactive demonstration of JudySL. Text 23 | // keywords are entered. The program uses that text as a key into a JudySL 24 | // array and increments a usage count. 25 | // 26 | // Keys can be single keywords like, "mykey", or multiple words like, "now is 27 | // the time for the quick brown fox to take the bull by the horns". 28 | // 29 | // The program recognizes the following keywords as special: 30 | // 31 | // CMD_LIST lists all the currently entered keys and their counts 32 | // CMD_QUIT terminates the program 33 | // 34 | // This program demonstrates: 35 | // 36 | // JudySLIns 37 | // JudySLFirst 38 | // JudySLNext 39 | // how to access a JudySL value 40 | // 41 | // Note: Using JudySL gives you fast lookups as with hashing but without 42 | // having to define a hash function, and without having to predetermine the 43 | // hash table size. It also gives you a sorted list at the same time. 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | #include "Judy.h" 50 | 51 | // Commands recognized by the program: 52 | 53 | #define CMD_LIST "list" 54 | #define CMD_QUIT "quit" 55 | 56 | #define PLURAL(count) ((count == 1) ? "" : "s") 57 | 58 | main() 59 | { 60 | char Index [BUFSIZ]; // value from user. 61 | void ** PPValue; // associated with Index. 62 | void * PArray = (Pvoid_t) NULL; // JudySL array. 63 | JError_t JError; // Judy error structure 64 | char * Pc; // place in string. 65 | 66 | // EMIT INSTRUCTIONS: 67 | 68 | (void) puts ("JudySL interactive demonstration:"); 69 | (void) puts ("When asked for input, enter some text or:"); 70 | (void) printf ("- \"%s\" to list previously entered text or\n", CMD_LIST); 71 | (void) printf ("- \"%s\" (or EOF) to quit the program\n\n", CMD_QUIT); 72 | 73 | 74 | // ACCEPT COMMANDS: 75 | 76 | while (1) 77 | { 78 | (void) printf ("\nEnter key/list/quit: "); 79 | (void) fflush (stdout); 80 | 81 | if (fgets (Index, BUFSIZ, stdin) == (char *) NULL) 82 | break; 83 | 84 | if ((Pc = strchr (Index, '\n')) != (char *) NULL) 85 | *Pc = '\0'; // strip trailing newline. 86 | 87 | // QUIT: 88 | 89 | if (! strcmp (Index, CMD_QUIT)) break; 90 | 91 | 92 | // LIST ALL INPUT IN ALPHABETICAL ORDER: 93 | 94 | if (! strcmp (Index, CMD_LIST)) 95 | { 96 | Index[0] = '\0'; 97 | 98 | for (PPValue = JudySLFirst (PArray, Index, 0); 99 | PPValue != (PPvoid_t) NULL; 100 | PPValue = JudySLNext (PArray, Index, 0)) 101 | { 102 | (void) printf (" \"%s\" stored %lu time%s\n", 103 | Index, *((PWord_t) PPValue), 104 | PLURAL (*((PWord_t) PPValue))); 105 | } 106 | 107 | continue; 108 | } 109 | 110 | 111 | // ALL OTHER VALUES ARE KEYS: 112 | // 113 | // Insert Index into the array. If Index already exists, JudySLIns() returns a 114 | // pointer to the old value. If Index doesn't already exist, then a slot is 115 | // created and a pointer to this slot (initialized to zero) is returned. 116 | 117 | if ((PPValue = JudySLIns (& PArray, Index, &JError)) == PPJERR) 118 | { // assume out of memory. 119 | (void) printf ("Error %d, cannot insert \"%s\" in array.\n", 120 | JU_ERRNO(&JError), Index); 121 | exit (1); 122 | } 123 | 124 | ++(*((PWord_t) PPValue)); // increment usage count. 125 | 126 | (void) printf (" \"%s\" stored %ld time%s\n", 127 | Index, *((PWord_t) PPValue), 128 | PLURAL (*((PWord_t) PPValue))); 129 | 130 | } // while 1 (continuous loop until user quits) 131 | 132 | exit (0); 133 | /*NOTREACHED*/ 134 | 135 | } // main() 136 | -------------------------------------------------------------------------------- /judy-1.0.5/src/apps/demo/run_demo: -------------------------------------------------------------------------------- 1 | # @(#) $Revision: 4.4 $ $Source: /judy/src/apps/demo/run_demo $ 2 | 3 | # Simple Judy example script. See the first block of text below, or just run 4 | # this with no arguments. 5 | 6 | BASE='interL' 7 | PROGRAM="$BASE.c" 8 | COMPILE="cc -I../.. -o $BASE $PROGRAM `find ../../ -name libJudy.a`" 9 | 10 | set -e # exit if anything goes wrong. 11 | 12 | 13 | # GREET THE USER: 14 | 15 | cat <<-'EOF' 16 | This script illustrates a simple program that calls the Judy library, 17 | shows how to compile it, and then runs it for you. 18 | 19 | The program reads numbers from standard input and stores them in a 20 | JudyL array as array indexes. The target value associated with each 21 | number (index) is the number of times it was duplicated in the input. 22 | Exit with ^D or ^C. 23 | 24 | Press RETURN to continue and view the program source code... 25 | EOF 26 | 27 | read input 28 | 29 | 30 | # SHOW THE SAMPLE C PROGRAM: 31 | 32 | echo '____________________________________' 33 | echo 34 | 35 | cat $PROGRAM 36 | 37 | echo 38 | echo 'Press RETURN to continue...' 39 | read input 40 | 41 | 42 | # COMPILE THE SAMPLE C PROGRAM: 43 | 44 | cat <<-EOF 45 | 46 | To compile this program with the Judy library already installed on your 47 | system, the simplest command line is: 48 | 49 | $COMPILE 50 | 51 | Press RETURN to continue and compile the program source code... 52 | EOF 53 | 54 | read input 55 | $COMPILE 56 | 57 | 58 | # RUN THE SAMPLE C PROGRAM: 59 | 60 | echo 61 | echo "Press RETURN to run the sample program \"$BASE\"..." 62 | read input 63 | 64 | ./$BASE 65 | -------------------------------------------------------------------------------- /judy-1.0.5/src/obj/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = @WARN_CFLAGS@ 2 | 3 | CLEANFILES = libJudy.la 4 | 5 | include_HEADERS = ../Judy.h 6 | 7 | lib_LTLIBRARIES = libJudy.la 8 | 9 | libJudy_la_SOURCES = 10 | 11 | libJudy_la_LIBADD = ../JudyCommon/*.lo ../JudyL/*.lo ../Judy1/*.lo ../JudyHS/*.lo ../JudySL/*.lo 12 | 13 | libJudy_la_LDFLAGS = @VERSION_INFO@ 14 | 15 | DISTCLEANFILES = .deps Makefile 16 | -------------------------------------------------------------------------------- /judy-1.0.5/test/CheckDupLines.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | //#include "JudyHS.h" // for Judy.h without JudyHS*() 8 | 9 | // By Doug Baskins Apr 2004 - for JudyHS man page 10 | 11 | #define MAXLINE 1000000 /* max length of line */ 12 | char Index[MAXLINE]; // string to check 13 | 14 | int // Usage: CheckDupLines < file 15 | main() 16 | { 17 | Pvoid_t PJArray = (PWord_t)NULL; // Judy array. 18 | PWord_t PValue; // Judy array element. 19 | Word_t Bytes; // size of JudyHS array. 20 | Word_t LineNumb = 0; // current line number 21 | Word_t Dups = 0; // number of duplicate lines 22 | 23 | while (fgets(Index, MAXLINE, stdin) != (char *)NULL) 24 | { 25 | LineNumb++; // line number 26 | 27 | // store string into array 28 | JHSI(PValue, PJArray, Index, strlen(Index)); 29 | if (*PValue) // check if duplicate 30 | { 31 | Dups++; // yes, count 32 | printf("Duplicate lines %lu:%lu:%s", *PValue, LineNumb, Index); 33 | } 34 | else 35 | { 36 | *PValue = LineNumb; // store Line number 37 | } 38 | } 39 | printf("%lu Duplicates, free JudyHS array of %lu Lines\n", 40 | Dups, LineNumb - Dups); 41 | JHSFA(Bytes, PJArray); // free array 42 | printf("The JudyHS array allocated %lu bytes of memory\n", Bytes); 43 | return (0); 44 | } 45 | -------------------------------------------------------------------------------- /judy-1.0.5/test/Checkit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | CC=${CC:-cc} 3 | 4 | echo 5 | echo "=== +++++++++ This test runs in 15 seconds on a PIII 750Mhz +++++++" 6 | 7 | LIBJUDY=`find ../ -name libJudy.a` 8 | JUDY_H=`find ../ -name Judy.h` 9 | 10 | echo "$CC -O SLcompare.c -DHASHMETHOD -o SL_Hash" 11 | $CC -O SLcompare.c -DHASHMETHOD -o SL_Hash 12 | 13 | echo "$CC -O SLcompare.c -DSPLAYMETHOD -o SL_Splay" 14 | $CC -O SLcompare.c -DSPLAYMETHOD -o SL_Splay 15 | 16 | echo "$CC -O SLcompare.c -DREDBLACKMETHOD -o SL_Redblack" 17 | $CC -O SLcompare.c -DREDBLACKMETHOD -o SL_Redblack 18 | 19 | echo 20 | echo Compiling with Judy library: $LIBJUDY 21 | echo 22 | 23 | echo "$CC -O -I../src SLcompare.c -DJUDYMETHOD -o SL_Judy $LIBJUDY -lm" 24 | $CC -O -I../src SLcompare.c -DJUDYMETHOD -o SL_Judy $LIBJUDY -lm 25 | RET=$? 26 | if [ $RET -ne 0 ] ; then 27 | echo "=== $? Failed: $CC SLcompare.c -DJUDYMETHOD" 28 | echo "=== $? Failed: $CC -O -I../src SLcompare.c -DJUDYMETHOD -o SL_Judy $LIBJUDY -lm" 29 | exit $? 30 | fi 31 | 32 | echo "$CC -O -I../src Judy1LHCheck.c -o Judy1LHCheck $LIBJUDY -lm" 33 | $CC -O -I../src Judy1LHCheck.c -o Judy1LHCheck $LIBJUDY -lm 34 | RET=$? 35 | if [ $RET -ne 0 ] ; then 36 | echo "=== $? Failed: $CC Judy1LHCheck.c" 37 | exit $? 38 | fi 39 | 40 | 41 | echo "$CC -O -I../src Judy1LHTime.c -DNOINLINE -o Judy1LHTime $LIBJUDY -lm" 42 | $CC -O -I../src Judy1LHTime.c -DNOINLINE -o Judy1LHTime $LIBJUDY -lm 43 | RET=$? 44 | if [ $RET -ne 0 ] ; then 45 | echo "=== $? Failed: $CC Judy1LHTime.c" 46 | exit $? 47 | fi 48 | 49 | # -OR- if Judy is installed, these can be compiled from anywhere: 50 | #cc -O SLcompare.c -DJUDYMETHOD -o SL_Judy -lJudy -lm 51 | #cc -O Judy1LHCheck.c -o Judy1LHCheck -lJudy -lm 52 | #cc -O Judy1LHTime.c -o Judy1LHTime -lJudy -lm 53 | echo "=== Pass: Compile of tests" 54 | 55 | echo 56 | echo " Validate Judy1/JudyL/JudyHS functions (except Judy*ByCount)" 57 | ./Judy1LHCheck -n 300000 -B20 > /dev/null 58 | RET=$? 59 | if [ $RET -ne 0 ] ; then 60 | echo "=== $? Failed: Judy1/JudyL/JudyHS validate program" 61 | exit $? 62 | fi 63 | echo "=== Pass: Judy1/JudyL/JudyHS validate program" 64 | 65 | 66 | echo 67 | echo " Do a few timings tests of Judy1/JudyL/JudyHS" 68 | echo 69 | # Pop1 is: current number of Indexes stored in Judy array 70 | # Measmts is: lookups to make measurement 71 | # J1 is: Judy1 72 | # JL is: JudyL 73 | # /I is: per Index 74 | # MU is: Memory Used (allocated thru malloc(3)) 75 | # HEAP is: Memory change measured with sbrk(0) 76 | echo " Pop1 Measmts J1S JLI J1T JLG J1MU/I JLMU/I HEAP/I" 77 | ./Judy1LHTime -n 2000000 -P1 -B19 | grep -v "^#" 78 | echo "=== Pass: Judy1/JudyL/JudyHS performance program" 79 | 80 | 81 | 82 | echo 83 | echo " Do a few timings tests of JudySL and friends" 84 | echo 85 | # lines is: number of lines in source file 86 | # avg_linelen is: average bytes per line 87 | # getline is: average time go get a line and remove white space 88 | # StoreD is: number of unique lines stored into JudySL array 89 | # RAMused/line is: Memory change measured with sbrk(0) 90 | # store/ln is: average insert time (including duplicates) 91 | # lookup/ln is: average lookup time in same order as inserts 92 | # ADT is: Abstract Data Type method 93 | echo " lines avg_linelen getline StoreD RAMused/line store/ln lookup/ln ADT" 94 | ./SL_Hash StringCompare.c | grep HASH 95 | ./SL_Splay StringCompare.c | grep SPLAY 96 | ./SL_Redblack StringCompare.c | grep REDBLACK 97 | ./SL_Judy StringCompare.c | grep JUDY 98 | RET=$? 99 | if [ $RET -ne 0 ] ; then 100 | echo "=== $? Failed: JudySL if StoreD numbers are all the same" 101 | exit $? 102 | fi 103 | echo "=== Pass: JudySL if StoreD numbers are all the same" 104 | echo 105 | -------------------------------------------------------------------------------- /judy-1.0.5/test/JudyString.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #define MAXLENSTR 1000000 8 | 9 | char Index[MAXLENSTR]; // string to store. 10 | 11 | Pvoid_t PJHArray = (PWord_t)NULL; // Judy array. 12 | 13 | // By Doug Baskins Apr 2004 - for JudyHS man page -- but too long 14 | 15 | int // Usage: JudyString file_to_store 16 | main(int argc, char *argv[]) 17 | { 18 | Pvoid_t PJHArray = (PWord_t)NULL; // Judy array. 19 | PWord_t PValue; // Judy array element. 20 | Word_t Bytes; // size of JudySL array. 21 | Word_t Len; // length of string 22 | FILE *fid = NULL; // stream id 23 | int Chr; // next char 24 | long Lines; // number of lines input file 25 | Word_t Dups; // Count duplicate lines 26 | 27 | if (argc < 2) 28 | { 29 | printf("Must supply input file in arg\n"); 30 | exit(2); 31 | } 32 | if ((fid = fopen(argv[1], "r")) == NULL) 33 | { 34 | printf("Failed to open '%s'\n", argv[1]); 35 | exit(2); 36 | } 37 | printf("Open '%s' and store strings in JudyHS array\n", argv[1]); 38 | 39 | Lines = 0; 40 | Len = 0; 41 | Dups = 0; 42 | while ((Chr = fgetc(fid)) != EOF) 43 | { 44 | if (Chr == '\n' && Len) 45 | { 46 | Index[Len] = '\0'; 47 | 48 | //printf("%3lu,%lu: %s\n", Lines, Len, Index); 49 | //printf("%s\n", Index); 50 | 51 | JHSI(PValue, PJHArray, Index, Len); // store string into array 52 | if (*PValue != 0) Dups++; 53 | *PValue += 1; 54 | Lines++; 55 | Len = 0; 56 | } 57 | else if (Len < MAXLENSTR) 58 | { 59 | Index[Len] = Chr; 60 | Len++; 61 | } 62 | } 63 | 64 | fclose(fid); 65 | fid = NULL; 66 | 67 | printf("'%s' has %lu lines, %lu duplicate lines\n", argv[1], Lines, Dups); 68 | 69 | printf("Re-open '%s' and verify each string is in JudyHS array\n", argv[1]); 70 | 71 | if ((fid = fopen(argv[1], "r")) == NULL) 72 | { 73 | printf("Failed to re-open '%s'\n", argv[1]); 74 | exit(2); 75 | } 76 | 77 | Lines = 0; 78 | Len = 0; 79 | while ((Chr = fgetc(fid)) != EOF) 80 | { 81 | if (Len < MAXLENSTR) Index[Len] = Chr; 82 | 83 | if (Chr == '\n' && Len) 84 | { 85 | Index[Len] = '\0'; 86 | 87 | JHSG(PValue, PJHArray, Index, Len); // store string into array 88 | if (PValue == NULL) 89 | { 90 | printf("'%s'\n", Index); 91 | printf("JHSG() failed at Line %lu\n", Lines); 92 | exit(1); 93 | } 94 | Len = 0; 95 | Lines++; 96 | } 97 | else Len++; 98 | } 99 | 100 | printf("Begin JHSFA (JudyHSFreeArray)\n"); 101 | 102 | JHSFA(Bytes, PJHArray); // free array 103 | 104 | fprintf(stderr, "JHSFA() free'ed %lu bytes of memory\n", Bytes); 105 | return (0); 106 | } 107 | -------------------------------------------------------------------------------- /judy-1.0.5/test/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = $(TESTS) 2 | 3 | TEST_ENVIRONMENT = top_builddir=$(top_builddir) 4 | 5 | TESTS = Checkit 6 | 7 | DISTCLEANFILES = .deps Makefile 8 | CLEANFILES = Judy1LHCheck Judy1LHTime Makefile SL_Hash SL_Judy SL_Redblack SL_Splay 9 | -------------------------------------------------------------------------------- /judy-1.0.5/test/README: -------------------------------------------------------------------------------- 1 | StringCompare.c Program to compare JudyHS with other ADT's 2 | Centrino_1.3Mhz_Plots/ Contains output of "StringCompare" on 1.3Mhz Centrino 3 | Checkit Script to validate Judy works before installing 4 | Judy1LHCheck.c Updated to include JudyHS() 5 | Judy1LHTime.c Updated to include JudyHS() 6 | jbgraph Script interface to 'gnuplot' to plot output of *Time.c progs. 7 | testjbgraph Demo script to show how to use jbgraph (1+ Minute) 8 | malloc-pre2.8a.c Only known malloc() (my me) that does not have performance 9 | problem, See: for later version. 10 | See: for further 11 | information. 12 | JudyMalloc.c For testing Judy free()s all memory that it malloc()ed. 13 | CheckDupLines.c For the JudyHS manual example 14 | JudyString.c For the JudyHS manual, but too long 15 | 16 | -- The following are obsolete. 17 | 18 | Judy1LCheck.c Program to test functionality of Judy API. (obsolete) 19 | Judy1LTime.c Program to time common Judy functions. (obsolete) 20 | SLcompare.c Program to compare JudySL performance with others (obsolete) 21 | timeit.c High resolution timers for certain platforms (obsolete) 22 | timeit.h High resolution timers for certain platforms (obsolete) 23 | -------------------------------------------------------------------------------- /judy-1.0.5/test/simple.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int Rc_int; 6 | 7 | int i; 8 | 9 | // Judy array to hold cached addresses 10 | Pvoid_t addrArray = (Pvoid_t) NULL; 11 | 12 | for(i = 0; i < 100000; i++) 13 | J1S(Rc_int, addrArray, (Word_t) i); 14 | 15 | for(i = 0; i < 100000; i++){ 16 | J1T(Rc_int, addrArray, (Word_t) i); 17 | if(!Rc_int){ 18 | printf("Something bad happened\n"); 19 | return -1; 20 | } 21 | } 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /judy-1.0.5/test/testjbgraph: -------------------------------------------------------------------------------- 1 | # run timing program to measure Judy1, JudyL and JudyHS performance 2 | # use jbgraph script to format output suitable for 'gnuplot' 3 | echo 4 | echo "This script takes 1 Minute to plot output on a 3.2Ghz Pentium P4C" 5 | 6 | # On Linux, higher resolution of times with -DCPUMHZ=3200 on 3.2Ghz 7 | # cc -O2 -DCPUMHZ=3200 Judy1LHTime.c -lJudy -lm -o Judy1LHTime 8 | 9 | # up to 1000000 population of random numbers with Judy1, JudyL, JudyHS 10 | ./Judy1LHTime -n 1000000 -1 -L -H > Judy1LHTime.plot 11 | 12 | # Plot the results: y-axis == uSec per Index, x-axis == number of Indexes 13 | # -NL == Plot No Log axis 14 | # -Lx == Plot Log in x axis 15 | # -y:1 == default min scale, 1 microsecond max scale 16 | # -x100: == 100 min scale, default max scale 17 | # -c6 -c7 -c8 == plot column 6,7,8 (J1T, JLG, JHSG) 18 | # Judy1LHTime.plot == file to plot 19 | ./jbgraph -NL -Lx -y:1 -x100: -c6 -c7 -c8 Judy1LHTime.plot 20 | 21 | # Performance of other ADT's can be explored with StringCompare.c, 22 | # but you should have a very large (>100MB) text file to input. 23 | -------------------------------------------------------------------------------- /judy-1.0.5/tool/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I. 2 | AM_CFLAGS = @CFLAGS@ @WARN_CFLAGS@ 3 | 4 | noinst_PROGRAMS = jhton 5 | 6 | jhton_SOURCES = jhton.c 7 | 8 | DISTCLEANFILES = .deps Makefile 9 | -------------------------------------------------------------------------------- /judy-1.0.5/tool/README: -------------------------------------------------------------------------------- 1 | 2 | # @(#) $Revision: 4.2 $ 3 | 4 | # CHECK README FILES AGAINST DIRECTORIES. 5 | 6 | # Usage: