Memcached-libmemcached-1.001801/0000755000175000017500000000000012527462751014656 5ustar seanseanMemcached-libmemcached-1.001801/.travis.yml0000644000175000017500000000034612522723506016763 0ustar seanseanlanguage: perl perl: - "5.18" - "5.16" - "5.14" - "5.12" - "5.10" services: - memcached before_install: - env | sort - sudo apt-get install libcloog-ppl0 - cpanm --verbose --installdeps --notest . || echo failed Memcached-libmemcached-1.001801/MANIFEST0000644000175000017500000007531112527462751016016 0ustar seansean.travis.yml Changes lib/Memcached/libmemcached/API.pm lib/Memcached/libmemcached/constants.pm lib/Memcached/libmemcached/memcached_analyze.pm lib/Memcached/libmemcached/memcached_auto.pm lib/Memcached/libmemcached/memcached_behavior.pm lib/Memcached/libmemcached/memcached_callback.pm lib/Memcached/libmemcached/memcached_create.pm lib/Memcached/libmemcached/memcached_delete.pm lib/Memcached/libmemcached/memcached_dump.pm lib/Memcached/libmemcached/memcached_flush.pm lib/Memcached/libmemcached/memcached_flush_buffers.pm lib/Memcached/libmemcached/memcached_generate_hash_value.pm lib/Memcached/libmemcached/memcached_get.pm lib/Memcached/libmemcached/memcached_memory_allocators.pm lib/Memcached/libmemcached/memcached_pool.pm lib/Memcached/libmemcached/memcached_quit.pm lib/Memcached/libmemcached/memcached_result_st.pm lib/Memcached/libmemcached/memcached_sasl.pm lib/Memcached/libmemcached/memcached_server_st.pm lib/Memcached/libmemcached/memcached_servers.pm lib/Memcached/libmemcached/memcached_set.pm lib/Memcached/libmemcached/memcached_stats.pm lib/Memcached/libmemcached/memcached_strerror.pm lib/Memcached/libmemcached/memcached_user_data.pm lib/Memcached/libmemcached/memcached_verbosity.pm lib/Memcached/libmemcached/memcached_version.pm libmemcached.pm libmemcached.xs Makefile.PL MANIFEST This list of files ppport.h README.md responses.csv responses.txt src/libmemcached/aclocal.m4 src/libmemcached/AUTHORS src/libmemcached/build-aux/config.guess src/libmemcached/build-aux/config.sub src/libmemcached/build-aux/depcomp src/libmemcached/build-aux/install-sh src/libmemcached/build-aux/ltmain.sh src/libmemcached/build-aux/missing src/libmemcached/build-aux/test-driver src/libmemcached/ChangeLog src/libmemcached/clients/client_options.h src/libmemcached/clients/execute.cc src/libmemcached/clients/execute.h src/libmemcached/clients/generator.cc src/libmemcached/clients/generator.h src/libmemcached/clients/include.am src/libmemcached/clients/memaslap.c src/libmemcached/clients/memcapable.cc src/libmemcached/clients/memcat.cc src/libmemcached/clients/memcp.cc src/libmemcached/clients/memdump.cc src/libmemcached/clients/memerror.cc src/libmemcached/clients/memexist.cc src/libmemcached/clients/memflush.cc src/libmemcached/clients/memparse.cc src/libmemcached/clients/memping.cc src/libmemcached/clients/memrm.cc src/libmemcached/clients/memslap.cc src/libmemcached/clients/memstat.cc src/libmemcached/clients/memtouch.cc src/libmemcached/clients/ms_atomic.h src/libmemcached/clients/ms_conn.c src/libmemcached/clients/ms_conn.h src/libmemcached/clients/ms_memslap.h src/libmemcached/clients/ms_setting.c src/libmemcached/clients/ms_setting.h src/libmemcached/clients/ms_sigsegv.c src/libmemcached/clients/ms_sigsegv.h src/libmemcached/clients/ms_stats.c src/libmemcached/clients/ms_stats.h src/libmemcached/clients/ms_task.c src/libmemcached/clients/ms_task.h src/libmemcached/clients/ms_thread.c src/libmemcached/clients/ms_thread.h src/libmemcached/clients/utilities.cc src/libmemcached/clients/utilities.h src/libmemcached/configure src/libmemcached/configure.ac src/libmemcached/COPYING src/libmemcached/docs/conf.py.in src/libmemcached/docs/include.am src/libmemcached/example/byteorder.cc src/libmemcached/example/byteorder.h src/libmemcached/example/include.am src/libmemcached/example/interface_v0.cc src/libmemcached/example/interface_v1.cc src/libmemcached/example/memcached_light.cc src/libmemcached/example/memcached_light.h src/libmemcached/example/storage.cc src/libmemcached/example/storage.h src/libmemcached/libhashkit-1.0/algorithm.h src/libmemcached/libhashkit-1.0/behavior.h src/libmemcached/libhashkit-1.0/configure.h src/libmemcached/libhashkit-1.0/configure.h.in src/libmemcached/libhashkit-1.0/digest.h src/libmemcached/libhashkit-1.0/function.h src/libmemcached/libhashkit-1.0/has.h src/libmemcached/libhashkit-1.0/hashkit.h src/libmemcached/libhashkit-1.0/hashkit.hpp src/libmemcached/libhashkit-1.0/include.am src/libmemcached/libhashkit-1.0/str_algorithm.h src/libmemcached/libhashkit-1.0/strerror.h src/libmemcached/libhashkit-1.0/string.h src/libmemcached/libhashkit-1.0/types.h src/libmemcached/libhashkit-1.0/visibility.h src/libmemcached/libhashkit/aes.cc src/libmemcached/libhashkit/aes.h src/libmemcached/libhashkit/algorithm.cc src/libmemcached/libhashkit/algorithm.h src/libmemcached/libhashkit/behavior.cc src/libmemcached/libhashkit/common.h src/libmemcached/libhashkit/crc32.cc src/libmemcached/libhashkit/digest.cc src/libmemcached/libhashkit/encrypt.cc src/libmemcached/libhashkit/fnv_32.cc src/libmemcached/libhashkit/fnv_64.cc src/libmemcached/libhashkit/function.cc src/libmemcached/libhashkit/has.cc src/libmemcached/libhashkit/hashkit.cc src/libmemcached/libhashkit/hashkit.h src/libmemcached/libhashkit/hashkitcon.h.in src/libmemcached/libhashkit/hsieh.cc src/libmemcached/libhashkit/include.am src/libmemcached/libhashkit/include.m4 src/libmemcached/libhashkit/is.h src/libmemcached/libhashkit/jenkins.cc src/libmemcached/libhashkit/ketama.cc src/libmemcached/libhashkit/md5.cc src/libmemcached/libhashkit/murmur.cc src/libmemcached/libhashkit/murmur3.cc src/libmemcached/libhashkit/murmur3.h src/libmemcached/libhashkit/murmur3_api.cc src/libmemcached/libhashkit/nohsieh.cc src/libmemcached/libhashkit/one_at_a_time.cc src/libmemcached/libhashkit/rijndael.cc src/libmemcached/libhashkit/rijndael.hpp src/libmemcached/libhashkit/str_algorithm.cc src/libmemcached/libhashkit/strerror.cc src/libmemcached/libhashkit/string.cc src/libmemcached/libhashkit/string.h src/libmemcached/libmemcached-1.0/alloc.h src/libmemcached/libmemcached-1.0/allocators.h src/libmemcached/libmemcached-1.0/analyze.h src/libmemcached/libmemcached-1.0/auto.h src/libmemcached/libmemcached-1.0/basic_string.h src/libmemcached/libmemcached-1.0/behavior.h src/libmemcached/libmemcached-1.0/callback.h src/libmemcached/libmemcached-1.0/callbacks.h src/libmemcached/libmemcached-1.0/configure.h src/libmemcached/libmemcached-1.0/configure.h.in src/libmemcached/libmemcached-1.0/defaults.h src/libmemcached/libmemcached-1.0/delete.h src/libmemcached/libmemcached-1.0/deprecated_types.h src/libmemcached/libmemcached-1.0/dump.h src/libmemcached/libmemcached-1.0/encoding_key.h src/libmemcached/libmemcached-1.0/error.h src/libmemcached/libmemcached-1.0/exception.hpp src/libmemcached/libmemcached-1.0/exist.h src/libmemcached/libmemcached-1.0/fetch.h src/libmemcached/libmemcached-1.0/flush.h src/libmemcached/libmemcached-1.0/flush_buffers.h src/libmemcached/libmemcached-1.0/get.h src/libmemcached/libmemcached-1.0/hash.h src/libmemcached/libmemcached-1.0/include.am src/libmemcached/libmemcached-1.0/limits.h src/libmemcached/libmemcached-1.0/memcached.h src/libmemcached/libmemcached-1.0/memcached.hpp src/libmemcached/libmemcached-1.0/options.h src/libmemcached/libmemcached-1.0/parse.h src/libmemcached/libmemcached-1.0/platform.h src/libmemcached/libmemcached-1.0/quit.h src/libmemcached/libmemcached-1.0/result.h src/libmemcached/libmemcached-1.0/return.h src/libmemcached/libmemcached-1.0/sasl.h src/libmemcached/libmemcached-1.0/server.h src/libmemcached/libmemcached-1.0/server_list.h src/libmemcached/libmemcached-1.0/stats.h src/libmemcached/libmemcached-1.0/storage.h src/libmemcached/libmemcached-1.0/strerror.h src/libmemcached/libmemcached-1.0/struct/allocator.h src/libmemcached/libmemcached-1.0/struct/analysis.h src/libmemcached/libmemcached-1.0/struct/callback.h src/libmemcached/libmemcached-1.0/struct/include.am src/libmemcached/libmemcached-1.0/struct/memcached.h src/libmemcached/libmemcached-1.0/struct/result.h src/libmemcached/libmemcached-1.0/struct/sasl.h src/libmemcached/libmemcached-1.0/struct/server.h src/libmemcached/libmemcached-1.0/struct/stat.h src/libmemcached/libmemcached-1.0/struct/string.h src/libmemcached/libmemcached-1.0/t/c_sasl_test.c src/libmemcached/libmemcached-1.0/t/c_test.c src/libmemcached/libmemcached-1.0/t/cc_test.cc src/libmemcached/libmemcached-1.0/t/include.am src/libmemcached/libmemcached-1.0/touch.h src/libmemcached/libmemcached-1.0/triggers.h src/libmemcached/libmemcached-1.0/types.h src/libmemcached/libmemcached-1.0/types/behavior.h src/libmemcached/libmemcached-1.0/types/callback.h src/libmemcached/libmemcached-1.0/types/connection.h src/libmemcached/libmemcached-1.0/types/hash.h src/libmemcached/libmemcached-1.0/types/include.am src/libmemcached/libmemcached-1.0/types/return.h src/libmemcached/libmemcached-1.0/types/server_distribution.h src/libmemcached/libmemcached-1.0/verbosity.h src/libmemcached/libmemcached-1.0/version.h src/libmemcached/libmemcached-1.0/visibility.h src/libmemcached/libmemcached/allocators.cc src/libmemcached/libmemcached/allocators.hpp src/libmemcached/libmemcached/analyze.cc src/libmemcached/libmemcached/array.c src/libmemcached/libmemcached/array.h src/libmemcached/libmemcached/assert.hpp src/libmemcached/libmemcached/auto.cc src/libmemcached/libmemcached/backtrace.cc src/libmemcached/libmemcached/backtrace.hpp src/libmemcached/libmemcached/behavior.cc src/libmemcached/libmemcached/behavior.hpp src/libmemcached/libmemcached/byteorder.cc src/libmemcached/libmemcached/byteorder.h src/libmemcached/libmemcached/callback.cc src/libmemcached/libmemcached/common.h src/libmemcached/libmemcached/connect.cc src/libmemcached/libmemcached/connect.hpp src/libmemcached/libmemcached/continuum.hpp src/libmemcached/libmemcached/csl/common.h src/libmemcached/libmemcached/csl/context.cc src/libmemcached/libmemcached/csl/context.h src/libmemcached/libmemcached/csl/include.am src/libmemcached/libmemcached/csl/parser.cc src/libmemcached/libmemcached/csl/parser.h src/libmemcached/libmemcached/csl/parser.yy src/libmemcached/libmemcached/csl/scanner.cc src/libmemcached/libmemcached/csl/scanner.h src/libmemcached/libmemcached/csl/scanner.l src/libmemcached/libmemcached/csl/server.h src/libmemcached/libmemcached/csl/symbol.h src/libmemcached/libmemcached/delete.cc src/libmemcached/libmemcached/do.cc src/libmemcached/libmemcached/do.hpp src/libmemcached/libmemcached/dump.cc src/libmemcached/libmemcached/encoding_key.cc src/libmemcached/libmemcached/encoding_key.h src/libmemcached/libmemcached/error.cc src/libmemcached/libmemcached/error.hpp src/libmemcached/libmemcached/exist.cc src/libmemcached/libmemcached/fetch.cc src/libmemcached/libmemcached/flag.cc src/libmemcached/libmemcached/flag.hpp src/libmemcached/libmemcached/flush.cc src/libmemcached/libmemcached/flush_buffers.cc src/libmemcached/libmemcached/get.cc src/libmemcached/libmemcached/hash.cc src/libmemcached/libmemcached/hash.hpp src/libmemcached/libmemcached/hosts.cc src/libmemcached/libmemcached/include.am src/libmemcached/libmemcached/initialize_query.cc src/libmemcached/libmemcached/initialize_query.h src/libmemcached/libmemcached/instance.cc src/libmemcached/libmemcached/instance.hpp src/libmemcached/libmemcached/internal.h src/libmemcached/libmemcached/io.cc src/libmemcached/libmemcached/io.h src/libmemcached/libmemcached/io.hpp src/libmemcached/libmemcached/is.h src/libmemcached/libmemcached/key.cc src/libmemcached/libmemcached/key.hpp src/libmemcached/libmemcached/libmemcached_probes.d src/libmemcached/libmemcached/libmemcached_probes.h src/libmemcached/libmemcached/memcached.cc src/libmemcached/libmemcached/memcached.h src/libmemcached/libmemcached/memcached.hpp src/libmemcached/libmemcached/memcached/protocol_binary.h src/libmemcached/libmemcached/memcached/README.txt src/libmemcached/libmemcached/memcached/vbucket.h src/libmemcached/libmemcached/memory.h src/libmemcached/libmemcached/namespace.cc src/libmemcached/libmemcached/namespace.h src/libmemcached/libmemcached/options.cc src/libmemcached/libmemcached/options.hpp src/libmemcached/libmemcached/parse.cc src/libmemcached/libmemcached/poll.cc src/libmemcached/libmemcached/poll.h src/libmemcached/libmemcached/purge.cc src/libmemcached/libmemcached/quit.cc src/libmemcached/libmemcached/quit.hpp src/libmemcached/libmemcached/response.cc src/libmemcached/libmemcached/response.h src/libmemcached/libmemcached/result.cc src/libmemcached/libmemcached/result.h src/libmemcached/libmemcached/sasl.cc src/libmemcached/libmemcached/sasl.hpp src/libmemcached/libmemcached/server.cc src/libmemcached/libmemcached/server.hpp src/libmemcached/libmemcached/server_instance.h src/libmemcached/libmemcached/server_list.cc src/libmemcached/libmemcached/server_list.hpp src/libmemcached/libmemcached/socket.hpp src/libmemcached/libmemcached/stats.cc src/libmemcached/libmemcached/storage.cc src/libmemcached/libmemcached/strerror.cc src/libmemcached/libmemcached/string.cc src/libmemcached/libmemcached/string.hpp src/libmemcached/libmemcached/touch.cc src/libmemcached/libmemcached/udp.cc src/libmemcached/libmemcached/udp.hpp src/libmemcached/libmemcached/util.h src/libmemcached/libmemcached/verbosity.cc src/libmemcached/libmemcached/version.cc src/libmemcached/libmemcached/version.hpp src/libmemcached/libmemcached/virtual_bucket.c src/libmemcached/libmemcached/virtual_bucket.h src/libmemcached/libmemcached/watchpoint.h src/libmemcached/libmemcached/windows.hpp src/libmemcached/libmemcachedinternal/include.am src/libmemcached/libmemcachedinternal/util/include.am src/libmemcached/libmemcachedprotocol-0.0/binary.h src/libmemcached/libmemcachedprotocol-0.0/callback.h src/libmemcached/libmemcachedprotocol-0.0/handler.h src/libmemcached/libmemcachedprotocol-0.0/include.am src/libmemcached/libmemcachedprotocol-0.0/vbucket.h src/libmemcached/libmemcachedprotocol/ascii_handler.c src/libmemcached/libmemcachedprotocol/ascii_handler.h src/libmemcached/libmemcachedprotocol/binary_handler.c src/libmemcached/libmemcachedprotocol/binary_handler.h src/libmemcached/libmemcachedprotocol/cache.c src/libmemcached/libmemcachedprotocol/cache.h src/libmemcached/libmemcachedprotocol/common.h src/libmemcached/libmemcachedprotocol/handler.c src/libmemcached/libmemcachedprotocol/include.am src/libmemcached/libmemcachedprotocol/pedantic.c src/libmemcached/libmemcachedutil-1.0/flush.h src/libmemcached/libmemcachedutil-1.0/include.am src/libmemcached/libmemcachedutil-1.0/ostream.hpp src/libmemcached/libmemcachedutil-1.0/pid.h src/libmemcached/libmemcachedutil-1.0/ping.h src/libmemcached/libmemcachedutil-1.0/pool.h src/libmemcached/libmemcachedutil-1.0/util.h src/libmemcached/libmemcachedutil-1.0/version.h src/libmemcached/libmemcachedutil/common.h src/libmemcached/libmemcachedutil/flush.cc src/libmemcached/libmemcachedutil/include.am src/libmemcached/libmemcachedutil/pid.cc src/libmemcached/libmemcachedutil/ping.cc src/libmemcached/libmemcachedutil/pool.cc src/libmemcached/libmemcachedutil/version.cc src/libmemcached/libtest/abort.cc src/libmemcached/libtest/alarm.cc src/libmemcached/libtest/alarm.h src/libmemcached/libtest/backtrace_test.cc src/libmemcached/libtest/binaries.cc src/libmemcached/libtest/binaries.h src/libmemcached/libtest/blobslap_worker.cc src/libmemcached/libtest/blobslap_worker.h src/libmemcached/libtest/callbacks.h src/libmemcached/libtest/client.cc src/libmemcached/libtest/client.hpp src/libmemcached/libtest/cmdline.cc src/libmemcached/libtest/cmdline.h src/libmemcached/libtest/collection.cc src/libmemcached/libtest/collection.h src/libmemcached/libtest/common.h src/libmemcached/libtest/comparison.cc src/libmemcached/libtest/comparison.hpp src/libmemcached/libtest/core.cc src/libmemcached/libtest/core.h src/libmemcached/libtest/core_count.cc src/libmemcached/libtest/cpu.cc src/libmemcached/libtest/cpu.hpp src/libmemcached/libtest/dns.cc src/libmemcached/libtest/dns.hpp src/libmemcached/libtest/dream.cc src/libmemcached/libtest/dream.h src/libmemcached/libtest/drizzled.cc src/libmemcached/libtest/drizzled.h src/libmemcached/libtest/error.h src/libmemcached/libtest/exception.cc src/libmemcached/libtest/exception.hpp src/libmemcached/libtest/exception/disconnected.hpp src/libmemcached/libtest/exception/fatal.cc src/libmemcached/libtest/exception/fatal.hpp src/libmemcached/libtest/formatter.cc src/libmemcached/libtest/formatter.hpp src/libmemcached/libtest/framework.cc src/libmemcached/libtest/framework.h src/libmemcached/libtest/gearmand.cc src/libmemcached/libtest/gearmand.h src/libmemcached/libtest/get.h src/libmemcached/libtest/has.cc src/libmemcached/libtest/has.hpp src/libmemcached/libtest/http.cc src/libmemcached/libtest/http.hpp src/libmemcached/libtest/include.am src/libmemcached/libtest/is_local.cc src/libmemcached/libtest/is_local.hpp src/libmemcached/libtest/is_pid.hpp src/libmemcached/libtest/killpid.cc src/libmemcached/libtest/killpid.h src/libmemcached/libtest/libtool.cc src/libmemcached/libtest/libtool.hpp src/libmemcached/libtest/lite.h src/libmemcached/libtest/m4/ax_lib_mysql.m4 src/libmemcached/libtest/m4/ax_prog_mysqld.m4 src/libmemcached/libtest/m4/mysql.m4 src/libmemcached/libtest/main.cc src/libmemcached/libtest/memcached.cc src/libmemcached/libtest/memcached.h src/libmemcached/libtest/memcached.hpp src/libmemcached/libtest/poll_error.hpp src/libmemcached/libtest/port.cc src/libmemcached/libtest/port.h src/libmemcached/libtest/result.cc src/libmemcached/libtest/result.hpp src/libmemcached/libtest/result/base.hpp src/libmemcached/libtest/result/fail.hpp src/libmemcached/libtest/result/skip.hpp src/libmemcached/libtest/result/success.hpp src/libmemcached/libtest/run.gdb src/libmemcached/libtest/runner.cc src/libmemcached/libtest/runner.h src/libmemcached/libtest/server.cc src/libmemcached/libtest/server.h src/libmemcached/libtest/server_container.cc src/libmemcached/libtest/server_container.h src/libmemcached/libtest/signal.cc src/libmemcached/libtest/signal.h src/libmemcached/libtest/skiptest.cc src/libmemcached/libtest/socket.cc src/libmemcached/libtest/socket.hpp src/libmemcached/libtest/stream.h src/libmemcached/libtest/strerror.cc src/libmemcached/libtest/strerror.h src/libmemcached/libtest/string.hpp src/libmemcached/libtest/test.h src/libmemcached/libtest/test.hpp src/libmemcached/libtest/thread.hpp src/libmemcached/libtest/timer.cc src/libmemcached/libtest/timer.hpp src/libmemcached/libtest/tmpfile.cc src/libmemcached/libtest/tmpfile.hpp src/libmemcached/libtest/unittest.cc src/libmemcached/libtest/valgrind.h src/libmemcached/libtest/vchar.cc src/libmemcached/libtest/vchar.hpp src/libmemcached/libtest/version.h src/libmemcached/libtest/version.h.in src/libmemcached/libtest/visibility.h src/libmemcached/libtest/wait.cc src/libmemcached/libtest/wait.h src/libmemcached/libtest/yatl.h src/libmemcached/libtest/yatl.m4 src/libmemcached/libtest/yatlcon.h.in src/libmemcached/m4/ax_add_am_macro.m4 src/libmemcached/m4/ax_am_jobserver.m4 src/libmemcached/m4/ax_am_macros.m4 src/libmemcached/m4/ax_append_compile_flags.m4 src/libmemcached/m4/ax_append_flag.m4 src/libmemcached/m4/ax_append_link_flags.m4 src/libmemcached/m4/ax_append_to_file.m4 src/libmemcached/m4/ax_assert.m4 src/libmemcached/m4/ax_check_compile_flag.m4 src/libmemcached/m4/ax_check_library.m4 src/libmemcached/m4/ax_check_link_flag.m4 src/libmemcached/m4/ax_compiler_vendor.m4 src/libmemcached/m4/ax_compiler_version.m4 src/libmemcached/m4/ax_count_cpus.m4 src/libmemcached/m4/ax_cxx_gcc_abi_demangle.m4 src/libmemcached/m4/ax_debug.m4 src/libmemcached/m4/ax_endian.m4 src/libmemcached/m4/ax_file_escapes.m4 src/libmemcached/m4/ax_gcc_atomic_builtins.m4 src/libmemcached/m4/ax_harden_compiler_flags.m4 src/libmemcached/m4/ax_hex_version.m4 src/libmemcached/m4/ax_libevent.m4 src/libmemcached/m4/ax_libmemcached.m4 src/libmemcached/m4/ax_memcached.m4 src/libmemcached/m4/ax_platform.m4 src/libmemcached/m4/ax_print_to_file.m4 src/libmemcached/m4/ax_prog_sphinx_build.m4 src/libmemcached/m4/ax_pthread.m4 src/libmemcached/m4/ax_pthread_timedjoin_np.m4 src/libmemcached/m4/ax_restore_flags.m4 src/libmemcached/m4/ax_sasl.m4 src/libmemcached/m4/ax_save_flags.m4 src/libmemcached/m4/ax_uuid.m4 src/libmemcached/m4/ax_vcs_checkout.m4 src/libmemcached/m4/ax_with_prog.m4 src/libmemcached/m4/bottom.m4 src/libmemcached/m4/byteorder.m4 src/libmemcached/m4/deprecated.m4 src/libmemcached/m4/fnv.m4 src/libmemcached/m4/gearmand.m4 src/libmemcached/m4/have_cinttypes.m4 src/libmemcached/m4/have_cstdint.m4 src/libmemcached/m4/hsieh.m4 src/libmemcached/m4/include.am src/libmemcached/m4/libgearman.m4 src/libmemcached/m4/libtool.m4 src/libmemcached/m4/ltoptions.m4 src/libmemcached/m4/ltsugar.m4 src/libmemcached/m4/ltversion.m4 src/libmemcached/m4/lt~obsolete.m4 src/libmemcached/m4/memaslap.m4 src/libmemcached/m4/murmur.m4 src/libmemcached/m4/pandora_enable_dtrace.m4 src/libmemcached/m4/protocol_binary.m4 src/libmemcached/m4/setsockopt.m4 src/libmemcached/m4/socket_send_flags.m4 src/libmemcached/m4/visibility.m4 src/libmemcached/Makefile.am src/libmemcached/Makefile.in src/libmemcached/man/hashkit_clone.3 src/libmemcached/man/hashkit_crc32.3 src/libmemcached/man/hashkit_create.3 src/libmemcached/man/hashkit_fnv1_32.3 src/libmemcached/man/hashkit_fnv1_64.3 src/libmemcached/man/hashkit_fnv1a_32.3 src/libmemcached/man/hashkit_fnv1a_64.3 src/libmemcached/man/hashkit_free.3 src/libmemcached/man/hashkit_functions.3 src/libmemcached/man/hashkit_hsieh.3 src/libmemcached/man/hashkit_is_allocated.3 src/libmemcached/man/hashkit_jenkins.3 src/libmemcached/man/hashkit_md5.3 src/libmemcached/man/hashkit_murmur.3 src/libmemcached/man/hashkit_value.3 src/libmemcached/man/include.am src/libmemcached/man/libhashkit.3 src/libmemcached/man/libmemcached.3 src/libmemcached/man/libmemcached_check_configuration.3 src/libmemcached/man/libmemcached_configuration.3 src/libmemcached/man/libmemcached_examples.3 src/libmemcached/man/libmemcachedutil.3 src/libmemcached/man/memaslap.1 src/libmemcached/man/memcached.3 src/libmemcached/man/memcached_add.3 src/libmemcached/man/memcached_add_by_key.3 src/libmemcached/man/memcached_analyze.3 src/libmemcached/man/memcached_append.3 src/libmemcached/man/memcached_append_by_key.3 src/libmemcached/man/memcached_behavior_get.3 src/libmemcached/man/memcached_behavior_set.3 src/libmemcached/man/memcached_callback_get.3 src/libmemcached/man/memcached_callback_set.3 src/libmemcached/man/memcached_cas.3 src/libmemcached/man/memcached_cas_by_key.3 src/libmemcached/man/memcached_clone.3 src/libmemcached/man/memcached_create.3 src/libmemcached/man/memcached_decrement.3 src/libmemcached/man/memcached_decrement_with_initial.3 src/libmemcached/man/memcached_delete.3 src/libmemcached/man/memcached_delete_by_key.3 src/libmemcached/man/memcached_destroy_sasl_auth_data.3 src/libmemcached/man/memcached_dump.3 src/libmemcached/man/memcached_exist.3 src/libmemcached/man/memcached_exist_by_key.3 src/libmemcached/man/memcached_fetch.3 src/libmemcached/man/memcached_fetch_execute.3 src/libmemcached/man/memcached_fetch_result.3 src/libmemcached/man/memcached_flush_buffers.3 src/libmemcached/man/memcached_free.3 src/libmemcached/man/memcached_generate_hash.3 src/libmemcached/man/memcached_generate_hash_value.3 src/libmemcached/man/memcached_get.3 src/libmemcached/man/memcached_get_by_key.3 src/libmemcached/man/memcached_get_memory_allocators.3 src/libmemcached/man/memcached_get_sasl_callbacks.3 src/libmemcached/man/memcached_get_user_data.3 src/libmemcached/man/memcached_increment.3 src/libmemcached/man/memcached_increment_with_initial.3 src/libmemcached/man/memcached_last_error_message.3 src/libmemcached/man/memcached_lib_version.3 src/libmemcached/man/memcached_mget.3 src/libmemcached/man/memcached_mget_by_key.3 src/libmemcached/man/memcached_mget_execute.3 src/libmemcached/man/memcached_mget_execute_by_key.3 src/libmemcached/man/memcached_pool.3 src/libmemcached/man/memcached_pool_behavior_get.3 src/libmemcached/man/memcached_pool_behavior_set.3 src/libmemcached/man/memcached_pool_create.3 src/libmemcached/man/memcached_pool_destroy.3 src/libmemcached/man/memcached_pool_fetch.3 src/libmemcached/man/memcached_pool_pop.3 src/libmemcached/man/memcached_pool_push.3 src/libmemcached/man/memcached_pool_release.3 src/libmemcached/man/memcached_pool_st.3 src/libmemcached/man/memcached_prepend.3 src/libmemcached/man/memcached_prepend_by_key.3 src/libmemcached/man/memcached_quit.3 src/libmemcached/man/memcached_replace.3 src/libmemcached/man/memcached_replace_by_key.3 src/libmemcached/man/memcached_sasl_set_auth_data.3 src/libmemcached/man/memcached_server_add.3 src/libmemcached/man/memcached_server_count.3 src/libmemcached/man/memcached_server_cursor.3 src/libmemcached/man/memcached_server_list.3 src/libmemcached/man/memcached_server_list_append.3 src/libmemcached/man/memcached_server_list_count.3 src/libmemcached/man/memcached_server_list_free.3 src/libmemcached/man/memcached_server_push.3 src/libmemcached/man/memcached_servers_parse.3 src/libmemcached/man/memcached_set.3 src/libmemcached/man/memcached_set_by_key.3 src/libmemcached/man/memcached_set_memory_allocators.3 src/libmemcached/man/memcached_set_sasl_callbacks.3 src/libmemcached/man/memcached_set_user_data.3 src/libmemcached/man/memcached_stat.3 src/libmemcached/man/memcached_stat_execute.3 src/libmemcached/man/memcached_stat_get_keys.3 src/libmemcached/man/memcached_stat_get_value.3 src/libmemcached/man/memcached_stat_servername.3 src/libmemcached/man/memcached_strerror.3 src/libmemcached/man/memcached_touch.3 src/libmemcached/man/memcached_touch_by_key.3 src/libmemcached/man/memcached_verbosity.3 src/libmemcached/man/memcached_version.3 src/libmemcached/man/memcapable.1 src/libmemcached/man/memcat.1 src/libmemcached/man/memcp.1 src/libmemcached/man/memdump.1 src/libmemcached/man/memerror.1 src/libmemcached/man/memexist.1 src/libmemcached/man/memflush.1 src/libmemcached/man/memparse.1 src/libmemcached/man/memping.1 src/libmemcached/man/memrm.1 src/libmemcached/man/memslap.1 src/libmemcached/man/memstat.1 src/libmemcached/man/memtouch.1 src/libmemcached/mem_config.in src/libmemcached/NEWS src/libmemcached/README src/libmemcached/README.FIRST src/libmemcached/README.win32 src/libmemcached/rpm/include.mk src/libmemcached/support/include.am src/libmemcached/support/libmemcached.pc.in src/libmemcached/support/libmemcached.spec src/libmemcached/support/libmemcached.spec.in src/libmemcached/support/set_benchmark.sh src/libmemcached/tests/basic.h src/libmemcached/tests/callbacks.h src/libmemcached/tests/cli.am src/libmemcached/tests/cpp_example.cc src/libmemcached/tests/cycle.cc src/libmemcached/tests/debug.h src/libmemcached/tests/deprecated.h src/libmemcached/tests/error_conditions.h src/libmemcached/tests/exist.h src/libmemcached/tests/failure.cc src/libmemcached/tests/hash_plus.cc src/libmemcached/tests/hash_results.h src/libmemcached/tests/hashkit_functions.cc src/libmemcached/tests/include.am src/libmemcached/tests/ketama.h src/libmemcached/tests/ketama_test_cases.h src/libmemcached/tests/ketama_test_cases_spy.h src/libmemcached/tests/keys.hpp src/libmemcached/tests/libmemcached-1.0/all_tests.cc src/libmemcached/tests/libmemcached-1.0/all_tests.h src/libmemcached/tests/libmemcached-1.0/all_tests_socket.cc src/libmemcached/tests/libmemcached-1.0/atomsmasher.cc src/libmemcached/tests/libmemcached-1.0/basic.cc src/libmemcached/tests/libmemcached-1.0/callback_counter.cc src/libmemcached/tests/libmemcached-1.0/callback_counter.h src/libmemcached/tests/libmemcached-1.0/callbacks.cc src/libmemcached/tests/libmemcached-1.0/debug.cc src/libmemcached/tests/libmemcached-1.0/deprecated.cc src/libmemcached/tests/libmemcached-1.0/dump.cc src/libmemcached/tests/libmemcached-1.0/dump.h src/libmemcached/tests/libmemcached-1.0/encoding_key.cc src/libmemcached/tests/libmemcached-1.0/encoding_key.h src/libmemcached/tests/libmemcached-1.0/error_conditions.cc src/libmemcached/tests/libmemcached-1.0/exist.cc src/libmemcached/tests/libmemcached-1.0/fetch_all_results.cc src/libmemcached/tests/libmemcached-1.0/fetch_all_results.h src/libmemcached/tests/libmemcached-1.0/generate.cc src/libmemcached/tests/libmemcached-1.0/generate.h src/libmemcached/tests/libmemcached-1.0/haldenbrand.cc src/libmemcached/tests/libmemcached-1.0/haldenbrand.h src/libmemcached/tests/libmemcached-1.0/include.am src/libmemcached/tests/libmemcached-1.0/internals.cc src/libmemcached/tests/libmemcached-1.0/ketama.cc src/libmemcached/tests/libmemcached-1.0/mem_functions.cc src/libmemcached/tests/libmemcached-1.0/mem_functions.h src/libmemcached/tests/libmemcached-1.0/memcached_get.cc src/libmemcached/tests/libmemcached-1.0/memcached_get.h src/libmemcached/tests/libmemcached-1.0/namespace.cc src/libmemcached/tests/libmemcached-1.0/parser.cc src/libmemcached/tests/libmemcached-1.0/parser.h src/libmemcached/tests/libmemcached-1.0/plus.cpp src/libmemcached/tests/libmemcached-1.0/pool.cc src/libmemcached/tests/libmemcached-1.0/print.cc src/libmemcached/tests/libmemcached-1.0/replication.cc src/libmemcached/tests/libmemcached-1.0/sasl.cc src/libmemcached/tests/libmemcached-1.0/server_add.cc src/libmemcached/tests/libmemcached-1.0/setup_and_teardowns.cc src/libmemcached/tests/libmemcached-1.0/setup_and_teardowns.h src/libmemcached/tests/libmemcached-1.0/stat.cc src/libmemcached/tests/libmemcached-1.0/stat.h src/libmemcached/tests/libmemcached-1.0/string.cc src/libmemcached/tests/libmemcached-1.0/touch.cc src/libmemcached/tests/libmemcached-1.0/virtual_buckets.cc src/libmemcached/tests/libmemcached_test_container.h src/libmemcached/tests/libmemcached_world.h src/libmemcached/tests/libmemcached_world_socket.h src/libmemcached/tests/mem_udp.cc src/libmemcached/tests/memc.hpp src/libmemcached/tests/memcapable.cc src/libmemcached/tests/memcat.cc src/libmemcached/tests/memcp.cc src/libmemcached/tests/memdump.cc src/libmemcached/tests/memerror.cc src/libmemcached/tests/memexist.cc src/libmemcached/tests/memflush.cc src/libmemcached/tests/memping.cc src/libmemcached/tests/memrm.cc src/libmemcached/tests/memslap.cc src/libmemcached/tests/memstat.cc src/libmemcached/tests/memtouch.cc src/libmemcached/tests/namespace.h src/libmemcached/tests/parser.am src/libmemcached/tests/parser.cc src/libmemcached/tests/pool.h src/libmemcached/tests/print.h src/libmemcached/tests/replication.h src/libmemcached/tests/runner.h src/libmemcached/tests/server_add.h src/libmemcached/tests/string.h src/libmemcached/tests/touch.h src/libmemcached/tests/virtual_buckets.h src/libmemcached/THANKS src/libmemcached/TODO src/libmemcached/util/daemon.cc src/libmemcached/util/daemon.hpp src/libmemcached/util/include.am src/libmemcached/util/instance.hpp src/libmemcached/util/log.hpp src/libmemcached/util/logfile.hpp src/libmemcached/util/operation.hpp src/libmemcached/util/pidfile.cc src/libmemcached/util/pidfile.hpp src/libmemcached/util/signal.hpp src/libmemcached/util/string.hpp src/libmemcached/version.m4 src/libmemcached/win32/include.am src/libmemcached/win32/wrappers.h src/libmemcached.patch src/README t/00-load.t t/01-import.t t/02-create.t t/02-subclass.t t/03-servers.t t/04-strerror.t t/05-behavior.t t/06-verbosity.t t/10-set-get.t t/11-set-get-by-key.t t/12-set-get-binary.t t/15-auto.t t/20-set.t t/21-set-by-key.t t/25-get.t t/26-get-cb.t t/27-set-cb.t t/28-get-prefix.t t/30-prepend-append.t t/31-prepend-append-by-key.t t/35-replace.t t/36-replace-by-key.t t/40-delete.t t/41-delete-by-key.t t/42-get_server_for_key.t t/50-quit.t t/51-flush.t t/60-stats.t t/80-result_st.t t/api-coverage.t t/extended-consistent-hashing.t t/lib/ExtUtils/ParseXS.pm t/lib/ExtUtils/xsubpp t/lib/libmemcached_test.pm t/pod-coverage.t t/pod.t TODO typemap META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Memcached-libmemcached-1.001801/Makefile.PL0000644000175000017500000003305412522723506016626 0ustar seanseanuse strict; use warnings; use ExtUtils::MakeMaker; use Config; use Getopt::Long; use Data::Dumper; use Cwd qw(getcwd abs_path); BEGIN { my $min = 5.006; if ($] < $min) { warn "Perl version $] is below minimum $min required. Upgrade!\n"; exit 0; } } my $lmcd_src = "src/libmemcached"; GetOptions( 'g!' => \my $opt_g, # enable debugging 'd!' => \my $opt_d, # debug Makefile.PL 'pg!' => \my $opt_pg, # enable profiling 'cov!' => \my $opt_cov, # enable test coverage analysis 'bin!' => \my $opt_bin, # install bintools from libmemcached 'src=s' => \$lmcd_src, # unpacked source code for libmemcached ) or exit 1; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; my $lmcd_api_ver = "1.0"; # eg $lmcd_src/libmemcached-$lmcd_api_ver/ my $lmcd_inst = getcwd()."/src_inst"; my $lmcd_built_lib = "$lmcd_inst/lib/libmemcached$Config{lib_ext}"; my $is_developer = (-d ".svn" || -d ".git"); my ($lmcd_h) = eval { build_libmemcached() }; if ($@) { warn "Unable to build libmemcached: $@\n"; warn "Aborted.\n"; exit 0; # tell cpan testers that this is not a failure } my %opts; if (my $gccversion = $Config{gccversion}) { # ask gcc to be more pedantic print "Your perl was compiled with gcc (version $Config{gccversion}), okay.\n"; $gccversion =~ s/[^\d\.]//g; # just a number please $opts{DEFINE} .= ' -W -Wall -Wpointer-arith -Wbad-function-cast'; $opts{DEFINE} .= ' -Wno-comment -Wno-sign-compare -Wno-cast-qual'; $opts{DEFINE} .= ' -Wmissing-noreturn -Wno-unused-parameter' if $gccversion ge "3.0"; if ($is_developer) { #$opts{DEFINE} .= ' -DPERL_GCC_PEDANTIC -ansi -pedantic' if $gccversion ge "3.0"; $opts{DEFINE} .= ' -Wdisabled-optimization -Wformat' if $gccversion ge "3.0"; $opts{DEFINE} .= ' -Wmissing-prototypes'; } } $opts{LIBS} = ["-lstdc++"]; # else error: libmemcached.so: undefined symbol: __gxx_personality_v0 $opts{OPTIMIZE} = "-g" if $opt_g; $opts{CCFLAGS} = "-pg" if $opt_pg; my $coverage_flags = ""; if ($opt_cov) { $opts{OPTIMIZE} = "-O0"; # http://search.cpan.org/~pjcj/Devel-Cover/gcov2perl $coverage_flags = "-fprofile-arcs -ftest-coverage"; $opts{CCFLAGS} = $coverage_flags; } ### optionally install the command line utilities that come with ### libmemcached as well if( $opt_bin ) { $opts{EXE_FILES} = [ map { s/\.c$//i; $_ } ]; } WriteMakefile( NAME => 'Memcached::libmemcached', AUTHOR => 'Tim Bunce ', VERSION_FROM => 'libmemcached.pm', ABSTRACT_FROM => 'libmemcached.pm', INC => "-I$lmcd_inst/include", # We want to link to *our* private libmemcached and not one that # might already be installed on the system. The LIBS config gets # appended to the link command line, so if we used "-L$dir -lmemcached" # then the installed lib would get preference over ours. # So we explicitly refer to our static library. That also avoids the # need to worry about what library might get used at runtime. LDFROM => '$(OBJECT)'." $lmcd_built_lib", PREREQ_PM => { 'Test::More' => 0, }, META_MERGE => { 'meta-spec' => { version => 2, }, resources => { bugtracker => { web => 'https://github.com/timbunce/Memcached-libmemcached/issues/', }, repository => { type => 'git', url => 'git://github.com/timbunce/Memcached-libmemcached.git', web => 'https://github.com/timbunce/Memcached-libmemcached', }, }, }, dynamic_lib => { OTHERLDFLAGS => ($opt_pg ? "-pg " : "") . ($opt_g ? "-g " : "") . $coverage_flags, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', DIST_DEFAULT=> 'clean distcheck disttest tardist', PREOP => '$(MAKE) -f Makefile.old distdir', }, # see also MY::postamble below clean => { FILES => 'Memcached-libmemcached-* lib/Memcached/libmemcached/*_hash.pl *.gcov libmemcached.gcda libmemcached.gcno', }, %opts, ); { package MY; sub postamble { return qq{ COVER = cover LMCD_SRC=$lmcd_src LMCD_API_VER=$lmcd_api_ver LMCD_INST=$lmcd_inst LMCD_BUILT_LIB=$lmcd_built_lib }.q{ coverclean: $(COVER) -delete testcover: coverclean pure_all HARNESS_PERL_SWITCHES='-MDevel::Cover=-coverage,branch,-coverage,condition,-coverage,pod,-coverage,statement,-coverage,subroutine' PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)','$(INST_ARCHLIB)')" $(TEST_FILES) gcov libmemcached.xs gcov2perl *.gcov $(COVER) clean :: realclean :: $(RM_RF) $(LMCD_INST) -cd $(LMCD_SRC) && $(MAKE) distclean libmemcached.c : $(XSUBPPDIR)/ParseXS.pm typemap $(OBJECT) : $(LMCD_BUILT_LIB) svnmanifest:: svn list -R -r HEAD | sort |grep -v '/$$' > MANIFEST svn diff MANIFEST svn status checkkeywords: $(RM_RF) blib find . -type f \( -name .svn -prune -o -name \*.pm -o -name \*.PL -o -name \*.pl \) \ -exec bash -c '[ -z "$$(svn pg svn:keywords {})" ] && echo svn propset svn:keywords \"Id Revision\" {}' \; checkpod: $(RM_RF) blib find . -type f \( -name .svn -prune -o -name \*.pm -o -name \*.PL -o -name \*.pl \) \ -exec podchecker {} \; 2>&1 | grep -v 'pod syntax OK' } } sub tool_xsubpp { #my $string = shift->SUPER::tool_xsubpp(@_); # Prepend -It/lib to XSUBPP (we do this instead of editing XSUBPPRUN because # XSUBPPRUN didn't exist in perl 5.6) return q{ XSUBPPDIR=t/lib/ExtUtils XSUBPP = -It/lib $(XSUBPPDIR)/xsubpp XSUBPPRUN = $(PERLRUN) $(XSUBPP) }; } } # end of package MY exit 0; sub run { my ($cmd) = @_; warn "$cmd\n"; system($cmd) == 0 or die "Error running $cmd\n"; } sub build_libmemcached { local $ENV{DESTDIR}; # do not let Perl module config leak through sync_libmemcached_pod(); extract_libmemcached_functions(); extract_libmemcached_constants(); return if -d "$lmcd_inst/lib"; # XXX assume it built ok. use 'make realclean' to rm mkdir $lmcd_inst, 0775 unless -d $lmcd_inst; run("cd $lmcd_src && make distclean") if -f "$lmcd_src/Makefile"; my $configure_args = '--with-pic';# --disable-shared'; $configure_args .= ' --disable-sasl'; # please fix $configure_args .= ' --with-lib-prefix=/opt/local' if -d "/opt/local" and $^O eq 'darwin'; # macports $configure_args .= ' --enable-debug' if $opt_g; $configure_args .= ' --enable-profiling' if $opt_pg; if ($is_developer) { # XXX make a Makefile.PL argument/option } $configure_args .= ' --disable-jobserver'; run("cd $lmcd_src && ./configure --prefix=$lmcd_inst $configure_args"); #run("cd $lmcd_src && make test") if $is_developer; # XXX run("cd $lmcd_src && make install"); } sub sync_libmemcached_pod { return unless -d ".svn"; # we duplicate the libmemcached pod in svn so that the docs can be read on search.cpan.org my $perl_pod_dir = "lib/Memcached/libmemcached"; my @lmcd_pod; warn "sync_libmemcached_pod XXXXXXXXXXXXXX"; for my $src_pod (@lmcd_pod) { (my $dst_pod = $src_pod) =~ s!$lmcd_src/docs!$perl_pod_dir!; $dst_pod =~ s/\.pod/\.pm/; open my $src, "<$src_pod" or die "Can't open $src_pod: $!"; open my $dst, ">$dst_pod" or die "Can't open $dst_pod: $!"; # convert path into package (my $dst_pkg = $dst_pod) =~ s{/}{::}g; $dst_pkg =~ s{ lib:: (.*?) \.\w+ $ }{$1}x; print $dst "package $dst_pkg;\n\n"; # for search.cpan.org while (<$src>) { print $dst $_; } print $dst "1;\n"; close $dst or die "Error closing $dst_pod: $!"; run("svn add -q $dst_pod"); } # XXX svn rm any $perl_pod_dir/memcached_*.pod that weren't in @lmcd_pod } sub extract_libmemcached_functions { my %libmemcached_func; # find all memcached_* functions warn "Finding all public functions\n"; my @headers = <$lmcd_src/libmemcached-$lmcd_api_ver/*.h>; for my $src_pod (@headers) { open my $fh, "<$src_pod" or die "Can't open $src_pod: $!"; #warn $src_pod; while (<$fh>) { next unless /\b(memcached_\w+)\s*\([^3]/; $libmemcached_func{$1} = 1 unless $1 eq 'memcached_return'; # parsing fooled by callback #warn "\t$1\t$_"; } } # write my $func_pm = "lib/Memcached/libmemcached/func_hash.pl"; warn "Writing $func_pm\n"; open my $func_pm_fh, ">$func_pm" or die "Can't open $func_pm: $!"; local $\ = "\n"; print $func_pm_fh "# DO NOT EDIT! GENERATED BY $0\n"; print $func_pm_fh "".Data::Dumper->Dump([\%libmemcached_func], [qw(libmemcached_func)]); close $func_pm_fh or die "Error closing $func_pm: $!"; # sanity check the generated file my $loaded = require $func_pm; die "$func_pm didn't return a HASH reference ($loaded)" unless ref $loaded eq 'HASH'; } sub extract_libmemcached_constants { my %libmemcached_const; # find all MEMCACHED_* constants (#define and enum) my $in_enum = 0; my @const; #my @headers = ("$lmcd_src/libmemcached/memcached.h", "$lmcd_src/libmemcached/constants.h"); my @headers = ( <$lmcd_src/libmemcached-$lmcd_api_ver/types/*.h>, "$lmcd_src/libmemcached-$lmcd_api_ver/limits.h", "$lmcd_src/libmemcached-$lmcd_api_ver/defaults.h", ); warn "Reading ".@headers." header files to find all constants\n"; for my $h (@headers) { warn " $h\n" if $opt_d; open my $fh, "<$h" or die "Can't open $h: $!"; while (<$fh>) { if ($in_enum) { if (m/^ \s* }/x) { # end of enum $libmemcached_const{$_} = $in_enum for @const; @const = (); $in_enum = 0; warn " << $in_enum" if $opt_d; } elsif (m/^ \s* (MEMCACHED_\w+)/x) { my $symbol = $1; if ( $symbol !~ /MEMCACHED_CALLBACK_(MALLOC|REALLOC|FREE)_FUNCTION/) { push @const, $symbol; warn " enum $_" if $opt_d; } } } elsif (m/^ \s* (?:typedef \s+)? enum \s+ (\w+) \s+ {/x) { $in_enum = $1; warn " >> $_" if $opt_d; } elsif (m/\# \s* define \s+ (MEMCACHED_\w+)/x) { my $symbol = $1; if ($symbol !~ /_H$/) { $libmemcached_const{$1} = "defines"; warn " $_" if $opt_d; } } } } # write raw hash of const names my $const_pl = "lib/Memcached/libmemcached/const_hash.pl"; warn "Writing $const_pl\n"; open my $const_pl_fh, ">$const_pl" or die "Can't open $const_pl: $!"; local $\ = "\n"; print $const_pl_fh "# DO NOT EDIT! GENERATED BY $0\n"; print $const_pl_fh "".Data::Dumper->Dump([\%libmemcached_const], [qw(libmemcached_const)]); close $const_pl_fh or die "Error closing $const_pl: $!"; # sanity check the generated file my $loaded = require $const_pl; die "$const_pl didn't return a HASH reference ($loaded)" unless ref $loaded eq 'HASH'; # write raw hash of const names my $const_xs = "const-xs.inc"; warn "Writing $const_xs\n"; open my $const_xs_fh, ">$const_xs" or die "Can't open $const_xs: $!"; local $\ = "\n"; print $const_xs_fh "# DO NOT EDIT! GENERATED BY $0\n"; print $const_xs_fh "IV\nconstant()"; print $const_xs_fh "\tALIAS:"; print $const_xs_fh "\t$_ = $_" for sort keys %libmemcached_const; print $const_xs_fh "\tCODE:"; print $const_xs_fh "\tRETVAL = ix;"; print $const_xs_fh "\tOUTPUT:"; print $const_xs_fh "\tRETVAL"; close $const_xs_fh or die "Error closing $const_xs: $!"; # now write a pod file to document the constants and tags # invert libmemcached_const into hash of tags with arrays of name my %libmemcached_tags; push @{ $libmemcached_tags{ $libmemcached_const{$_} } }, $_ for keys %libmemcached_const; # open file and write prologue my $const_pm = "lib/Memcached/libmemcached/constants.pm"; warn "Writing $const_pm\n"; open my $const_pm_fh, ">$const_pm" or die "Can't open $const_pm: $!"; local $\ = "\n"; print $const_pm_fh "# DO NOT EDIT! GENERATED BY $0\n"; print $const_pm_fh $_ for ( "=head1 NAME\n", "Memcached::libmemcached::constants - document list of constants defined by libmemcached\n", "=head1 DESCRIPTION\n", "This file just lists all the constants defined by libmemcached which are available to import via the L module.\n", "Each constant can be imported individually by name. " ."Groups of related constants, such as the elements of an C type, " ."can be imported as a set using a C<:tag> name. " ."See L for more information about tags.\n", ); # write out tags and their constants print $const_pm_fh "=head1 TAGS\n"; for my $tag (sort keys %libmemcached_tags) { my $names = $libmemcached_tags{$tag} or die "panic"; print $const_pm_fh "=head2 :$tag\n"; print $const_pm_fh " $_" for sort @$names; print $const_pm_fh ""; } # close up print $const_pm_fh "=cut\n\n1;\n"; close $const_pm_fh or die "Error closing $const_pm: $!"; # run("svn add -q $const_pm") if $is_developer; } Memcached-libmemcached-1.001801/t/0000755000175000017500000000000012527462751015121 5ustar seanseanMemcached-libmemcached-1.001801/t/03-servers.t0000644000175000017500000000156712522723506017221 0ustar seansean # tests for functions documented in memcached_servers.pod use strict; use warnings; use Test::More tests => 10; BEGIN { use_ok( 'Memcached::libmemcached', # functions explicitly tested by this file qw( memcached_server_count memcached_server_add memcached_server_add_unix_socket ), # other functions used by the tests qw( memcached_create memcached_free )); } my $memc; ok $memc = memcached_create(undef); is memcached_server_count($memc), 0, 'should have 0 elements'; ok memcached_server_add($memc, "bar", 1234); is memcached_server_count($memc), 1, 'should have 1 element'; ok memcached_server_add($memc, "foo"); is memcached_server_count($memc), 2, 'should have 2 elements'; ok memcached_server_add_unix_socket($memc, "/tmp/none-such-libmemcached-socket"); is memcached_server_count($memc), 3, 'should have 3 elements'; # XXX memcached_free # ok 1; Memcached-libmemcached-1.001801/t/42-get_server_for_key.t0000644000175000017500000000131512522723506021405 0ustar seansean# tests for functions documented in memcached_create.pod use strict; use warnings; use Test::More tests => 8; BEGIN { use_ok( 'Memcached::libmemcached', # functions explicitly tested by this file qw( ), # other functions used by the tests qw( memcached_server_add )); } my ($memc); ok $memc = Memcached::libmemcached->new(); is ref $memc, 'Memcached::libmemcached'; ok memcached_server_add($memc, "localhost", 11211); ok memcached_server_add($memc, "localhost", 11212); ok $memc->get_server_for_key("test3") eq "localhost:11211", "get_server_for_key test3 == localhost:11211"; ok $memc->get_server_for_key("test") eq "localhost:11212", "get_server_for_key test == localhost:11212"; undef $memc; ok 1; Memcached-libmemcached-1.001801/t/35-replace.t0000644000175000017500000000166212522723506017144 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_replace ), # other functions used by the tests qw( memcached_set memcached_get memcached_errstr ); use lib 't/lib'; use libmemcached_test; my $k1= "replace-".time(); my $orig= 'original content'; my $repl= 'replaced stuff'; my $flags; my $rc; my $memc = libmemcached_test_create({ min_version => "1.2.4" }); plan tests => 6; ok !memcached_replace($memc, $k1, $repl), 'should fail on non-existing key'; ok memcached_set($memc, $k1, $orig); ok memcached_replace($memc, $k1, $repl); my $ret= memcached_get($memc, $k1, $flags=0, $rc=0); ok $rc, 'memcached_get should work'; ok defined $ret, 'memcached_get result should be defined'; cmp_ok $ret, 'eq', $repl, 'should return replaced value'; Memcached-libmemcached-1.001801/t/02-create.t0000644000175000017500000000120512522723506016757 0ustar seansean# tests for functions documented in memcached_create.pod use strict; use warnings; # XXX memcached_clone needs more testing for non-undef args use Test::More tests => 5; BEGIN { use_ok( 'Memcached::libmemcached', # functions explicitly tested by this file qw( memcached_create memcached_free memcached_clone ), # other functions used by the tests qw( )); } my ($memc, $memc2); ok $memc = memcached_create(); memcached_free($memc); ok $memc = memcached_create(); ok $memc2 = memcached_clone(undef, undef); memcached_free($memc2); memcached_free($memc); print "duplicate memcached_free\n"; memcached_free($memc); ok 1; Memcached-libmemcached-1.001801/t/15-auto.t0000644000175000017500000000236112522723506016474 0ustar seansean # tests for functions documented in memcached_auto.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_increment memcached_decrement ), # other functions used by the tests qw( memcached_set ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 9; my $t1= time(); my $k1= "$0-test-key-$t1"; # can't have spaces my $v1= 42; my $v2=0; print "memcached_increment the not yet stored value\n"; ok !memcached_increment($memc, $k1, 1, $v2), 'should not exist yet and so should return false'; ok defined memcached_increment($memc, $k1, 1, $v2), 'should not exist yet and so should return false but defined'; print "memcached_set\n"; ok memcached_set($memc, $k1, $v1); print "memcached_increment the just stored value\n"; ok memcached_increment($memc, $k1, 1, $v2), 'should increment existing value'; is $v2, $v1+1; ok memcached_increment($memc, $k1, 1, $v2), 'should increment existing value'; is $v2, $v1+2; ok memcached_decrement($memc, $k1, 1, $v2), 'should increment existing value'; is $v2, $v1+1; # repeat for value with a null byte to check value_length works Memcached-libmemcached-1.001801/t/41-delete-by-key.t0000644000175000017500000000147212522723506020165 0ustar seansean # tests for functions documented in memcached_delete.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_delete_by_key ), # other functions used by the tests qw( memcached_set_by_key memcached_get_by_key ); use lib 't/lib'; use libmemcached_test; my $t1= time(); my $m1= "master-key"; # can't have spaces my $k1= "$0-test-key-$t1"; # can't have spaces my $v1= "$0 test value $t1"; my $ret; my $memc = libmemcached_test_create(); plan tests => 6; ok $memc; ok memcached_set_by_key($memc, $m1, $k1, $v1); ok $ret= memcached_get_by_key($memc, $m1, $k1); cmp_ok $ret, 'eq', $v1, 'should be equal'; ok memcached_delete_by_key($memc, $m1, $k1); ok !memcached_get_by_key($memc, $m1, $k1); Memcached-libmemcached-1.001801/t/30-prepend-append.t0000644000175000017500000000160712522723506020425 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_prepend memcached_append ), # other functions used by the tests qw( memcached_set memcached_get ); use lib 't/lib'; use libmemcached_test; my $pre= 'begin '; my $end= ' end'; my $k1= 'abc'; my $flags; my $rc; my $memc = libmemcached_test_create({ min_version => "1.2.4" }); plan tests => 6; my $orig = "middle"; ok memcached_set($memc, $k1, $orig); ok memcached_prepend($memc, $k1, $pre); ok memcached_append($memc, $k1, $end); my $ret= memcached_get($memc, $k1, $flags=0, $rc=0); ok $rc, 'memcached_get rc should be true'; ok defined $ret, 'memcached_get result should be defined'; my $combined= $pre . $orig . $end; cmp_ok $ret, 'eq', $combined; Memcached-libmemcached-1.001801/t/06-verbosity.t0000644000175000017500000000055512522723506017555 0ustar seansean # tests for functions documented in memcached_verbosity.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 1; ok $memc; Memcached-libmemcached-1.001801/t/40-delete.t0000644000175000017500000000065712522723506016772 0ustar seansean # tests for functions documented in memcached_delete.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_delete ), # other functions used by the tests qw( memcached_set memcached_get ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 1; ok $memc; Memcached-libmemcached-1.001801/t/api-coverage.t0000644000175000017500000000141612522723506017643 0ustar seanseanuse strict; use warnings; use Test::More; # t/pod-coverage shows what's been implemented but not documented # t/api-coverage shows what's in the libmemcached API but not documented use Memcached::libmemcached::API; my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing" if $@; plan tests => 1; my $pc = Pod::Coverage->new(package => 'Memcached::libmemcached'); my %covered = map { $_=>1 } $pc->covered; my @todo; print "libmemcached_functions:\n"; for my $func (libmemcached_functions()) { print "$func\n"; push @todo, $func unless $covered{$func}; } if (@todo) { warn " ".scalar(@todo)." Functions not yet implemented and documented:\n"; warn "\t$_\n" for @todo; } pass; # don't treat as a failure Memcached-libmemcached-1.001801/t/60-stats.t0000644000175000017500000000365712522723506016673 0ustar seansean # tests for functions documented in memcached_stats.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( memcached_server_count ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 8; ok $memc; # walk_stats() { # statistics information actually change from version to version, # so we can't even be sure of the number of tests. # We could probably do a version specific testing, but for now # just check that the some constant items/constraints stay constant. my $arg_count_ok = 1; my $keys_defined_ok = 1; my $hostport_defined_ok = 1; my $type_ok = 1; my (%seen_hostport, %seen_distinct); my $walk_stats_rc = $memc->walk_stats("", sub { $arg_count_ok = scalar(@_) == 4 if $arg_count_ok; my ($key, $value, $hostport, $type) = @_; # $type is deprecated print "$hostport $type: $key=$value\n"; $keys_defined_ok = defined $key if $keys_defined_ok; $hostport_defined_ok = defined $hostport if $hostport_defined_ok; $type_ok = defined $type && "" eq $type if $type_ok; $seen_hostport{$hostport} = 1; $seen_distinct{"$hostport:$key"}++; # XXX build $seen_hostport{$hostport} and it matches memcached_server_count # XXX build hash return; }); ok( $walk_stats_rc, "walk_stats should return true"); ok( $arg_count_ok, "walk_stats argument count is sane" ); ok( $keys_defined_ok, "keys are sane" ); ok( $hostport_defined_ok, "hostport are sane" ); ok( $type_ok, "types are sane" ); is( scalar keys %seen_hostport, memcached_server_count($memc), "should see responses from each server"); is( scalar (grep { $_ != 1 } values %seen_distinct), 0, "should see no distinct hostport+key more than once"); } Memcached-libmemcached-1.001801/t/extended-consistent-hashing.t0000644000175000017500000000315612522723506022712 0ustar seanseanuse strict; use Test::More; use lib 't/lib'; use libmemcached_test; # This test requires at least 5 memcached instances. # We start out by creating 100 items in 4 instances. # After that, we add another server to the server list, and # do the fetch of the 100 items. When used with consistent hashing, we # should be getting around 80% hit ratio my @servers; BEGIN { @servers = libmemcached_test_servers(); plan skip_all => "Set PERL_LIBMEMCACHED_TEST_SERVERS env var to at least 5 servers to run this test" if @servers < 5; plan(tests => 2); use_ok("Cache::Memcached::libmemcached", "MEMCACHED_DISTRIBUTION_CONSISTENT"); } my $max = 100; { # First, flush everything in these test memcached my $cache = Cache::Memcached::libmemcached->new({ servers => \@servers, }); $cache->flush_all; } { # Now, warm 4 out of 5 servers my $cache = Cache::Memcached::libmemcached->new({ servers => [ @servers[0..3] ], distribution_method => MEMCACHED_DISTRIBUTION_CONSISTENT, }); for (1..$max) { $cache->set($_ => $_); } } { # 4 caches have been warmed. add another cache, and our hit ratio should # be somewhere around 0.80 (we'll allow plus-or-minus 0.05 my $hits = 0; my $cache = Cache::Memcached::libmemcached->new({ servers => [ @servers[0..4] ], distribution_method => MEMCACHED_DISTRIBUTION_CONSISTENT, }); for (1..$max) { if (defined $cache->get($_)) { $hits++; } } my $ratio = $hits / $max; ok( $ratio >= 0.75 && $ratio <= 0.85, "Hit ratio is somewhere around 0.80 (was $ratio)" ); } Memcached-libmemcached-1.001801/t/12-set-get-binary.t0000644000175000017500000000161412522723506020353 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_set memcached_get ), # other functions used by the tests qw( memcached_server_add memcached_create memcached_behavior_set memcached_free memcached_errstr ), # binary protocol constant qw( MEMCACHED_BEHAVIOR_BINARY_PROTOCOL ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create({ min_version => "1.4.0" }); plan tests => 5; ok memcached_behavior_set($memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); my $val = 'this is a test'; ok memcached_set($memc, 'abc', $val); is memcached_errstr($memc), 'SUCCESS'; my ($flags, $rc); is memcached_get($memc, 'abc', $flags=0, $rc=0), $val; ok $rc; Memcached-libmemcached-1.001801/t/00-load.t0000644000175000017500000000140112522723506016427 0ustar seansean#!perl -T use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok( 'Memcached::libmemcached' ); } my $VERSION = $Memcached::libmemcached::VERSION; ok $VERSION, '$Memcached::libmemcached::VERSION should be defined'; diag( "Testing Memcached::libmemcached $VERSION, Perl $], $^O, $^X" ); ok defined &Memcached::libmemcached::memcached_lib_version, '&Memcached::libmemcached::memcached_lib_version should be defined'; my $lib_version = Memcached::libmemcached::memcached_lib_version(); # 1.0.8 ok $lib_version; # 1.0.8 => 1.00.08 (my $lib_ver = $lib_version) =~ s/\.(\d)\b/ sprintf ".%02d", $1 /eg; $lib_ver =~ s/\.(\d+)$/$1/; # drop second period like $VERSION, qr/^\Q$lib_ver\E\d\d/, "$VERSION should be $lib_ver with two digits appended", Memcached-libmemcached-1.001801/t/80-result_st.t0000644000175000017500000000055512522723506017555 0ustar seansean # tests for functions documented in memcached_result_st.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 1; ok $memc; Memcached-libmemcached-1.001801/t/04-strerror.t0000644000175000017500000000206512522723506017405 0ustar seansean # tests for functions documented in memcached_strerror.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_strerror memcached_errstr ), # other functions used by the tests qw( memcached_server_add_unix_socket MEMCACHED_INVALID_ARGUMENTS ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 6; $| = 1; is memcached_strerror($memc, 0), 'SUCCESS'; is memcached_strerror($memc, 1), 'FAILURE'; # XXX also test dual-var nature of return codes here my $rc = memcached_server_add_unix_socket($memc, undef); # should fail is $rc, undef, 'rc should not be defined'; my $errstr = $memc->errstr; #use Devel::Peek; Dump($errstr); cmp_ok $errstr, '==', MEMCACHED_INVALID_ARGUMENTS(), 'should be MEMCACHED_INVALID_ARGUMENTS integer in numeric context'; cmp_ok $errstr, 'eq', "INVALID ARGUMENTS", 'should be "INVALID ARGUMENTS" string in string context'; is $errstr, memcached_errstr($memc); Memcached-libmemcached-1.001801/t/28-get-prefix.t0000644000175000017500000000254312522723506017604 0ustar seansean # tests for functions documented in memcached_get.pod # (except for memcached_fetch_result) use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_callback_set memcached_callback_get MEMCACHED_CALLBACK_PREFIX_KEY MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY ), # other functions used by the tests qw( memcached_set memcached_get ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); my $expire = 5; plan tests => 13; ok $memc->memcached_set("f1:a", 4201, $expire); ok $memc->memcached_set("f2:a", 4202, $expire); is $memc->memcached_get("f1:a"), 4201; is $memc->memcached_get("f2:a"), 4202; ok $memc->memcached_callback_set(MEMCACHED_CALLBACK_PREFIX_KEY, "f1:"); is $memc->memcached_callback_get(MEMCACHED_CALLBACK_PREFIX_KEY), "f1:"; is $memc->memcached_get("a"), 4201; ok $memc->memcached_callback_set(MEMCACHED_CALLBACK_PREFIX_KEY, "f2:"); is $memc->memcached_callback_get(MEMCACHED_CALLBACK_PREFIX_KEY), "f2:"; is $memc->memcached_get("a"), 4202; TODO: { local $TODO = "MEMCACHED_CALLBACK_PREFIX_KEY should allow empty prefix"; ok $memc->memcached_callback_set(MEMCACHED_CALLBACK_PREFIX_KEY, ""); is $memc->memcached_get("f1:a"), 4201; is $memc->memcached_get("f2:a"), 4202; } Memcached-libmemcached-1.001801/t/36-replace-by-key.t0000644000175000017500000000241412522723506020337 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_replace_by_key ), # other functions used by the tests qw( memcached_set_by_key memcached_get_by_key memcached_errstr ); use lib 't/lib'; use libmemcached_test; my $m1= "master-key"; my $k1= "replace-".libmemcached_test_key(); my $orig= 'original content'; my $repl= 'replaced stuff'; my $flags; my $rc; my $memc = libmemcached_test_create({ min_version => "1.2.4" }); plan tests => 6; ok !memcached_replace_by_key($memc, $m1, $k1, $repl), 'should fail on non-existing key'; ok memcached_set_by_key($memc, $m1, $k1, $orig); ok memcached_replace_by_key($memc, $m1, $k1, $repl); my $ret= memcached_get_by_key($memc, $m1, $k1, $flags=0, $rc=0); ok $rc, 'memcached_get_by_key rc should be true'; ok defined $ret, 'memcached_get_by_key result should be defined'; cmp_ok $ret, 'eq', $repl, 'should return replaced value'; # XXX I don't think "should fail on non-existing master key" is right # when there's only one server #ok !memcached_replace_by_key($memc, 'bogus-master-key', $k1, $repl), # 'should fail on non-existing master key'; Memcached-libmemcached-1.001801/t/10-set-get.t0000644000175000017500000000373712522723506017077 0ustar seansean # tests for basic memcached_set & memcached_get # documented in memcached_set.pod and memcached_get.pod # test for the other functions are performed elsewhere use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_set memcached_get ), # other functions used by the tests qw( memcached_errstr memcached_version MEMCACHED_NOTFOUND ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 14; diag "Testing using memcached version ".memcached_version($memc); my ($rv, $rc, $flags, $tmp); my $t1= time(); my $k1= "$0-test-key-$t1"; # can't have spaces my $v1= "$0 test value $t1"; # get (presumably non-existant) key is scalar memcached_get($memc, $k1, $flags=0, $rc=0), undef, 'should not exist yet and so should return undef'; # test set with expiry and flags ok memcached_set($memc, $k1, $v1, 1, 0xDEADCAFE); is memcached_errstr($memc), 'SUCCESS'; is memcached_get($memc, $k1, $flags=0, $rc=0), $v1; ok $rc; if ($flags == 0xCAFE) { warn "You're limited to 16 bit flags\n"; $flags = 0xDEADCAFE; } if ($flags == 0 && not libmemcached_version_ge($memc, "1.2.4")) { warn "You're old memcached version doesn't support flags!\n"; $flags = 0xDEADCAFE; } is sprintf("0x%X",$flags), '0xDEADCAFE', 'flags should be unchanged'; sleep 2; # 1 second expiry plus 1 for safety margin ok not defined memcached_get($memc, $k1, $flags=0, $rc=0); ok !$rc; cmp_ok memcached_errstr($memc), '==', MEMCACHED_NOTFOUND(); # repeat for value with a null byte to check value_length works my $smiley = "\x{263A}"; ok memcached_set($memc, $k1, $tmp = $smiley); is length $tmp, length $smiley, 'utf8 arg length should not be altered'; is $tmp, $smiley, 'utf8 arg should not be altered'; $tmp = memcached_get($memc, $k1, $flags, $rc=0); ok $rc; { local $TODO = "support utf8"; # XXX is $tmp, $smiley; pass "no inbuilt utf8 support\n"; } Memcached-libmemcached-1.001801/t/01-import.t0000644000175000017500000000353612522723506017036 0ustar seansean# tests for functions documented in memcached_create.pod use strict; use warnings; use Carp; use Test::More tests => 16; BEGIN { use_ok( 'Memcached::libmemcached' ) } #$Exporter::Verbose = 1; ok !defined &memcached_create, 'should not import func by default'; Memcached::libmemcached->import( 'memcached_create' ); ok defined &memcached_create, 'should import func on demand'; # we use exists not defined for constants because they're handled by AUTOLOAD ok !exists &MEMCACHED_SUCCESS, 'should not import MEMCACHED_SUCCESS by default'; ok !exists &MEMCACHED_FAILURE, 'should not import MEMCACHED_FAILURE by default'; Memcached::libmemcached->import( 'MEMCACHED_SUCCESS' ); ok exists(&MEMCACHED_SUCCESS), 'should import MEMCACHED_SUCCESS on demand'; ok !exists &MEMCACHED_FAILURE, 'should not import MEMCACHED_FAILURE when importing MEMCACHED_SUCCESSi'; ok defined MEMCACHED_SUCCESS(); ok !exists &MEMCACHED_HASH_MD5, 'should not import MEMCACHED_HASH_MD5 by default'; ok !exists &MEMCACHED_HASH_CRC, 'should not import MEMCACHED_HASH_CRC by default'; Memcached::libmemcached->import( ':memcached_hash_t' ); ok exists &MEMCACHED_HASH_MD5, 'should import MEMCACHED_HASH_MD5 by :memcached_hash tag'; ok exists &MEMCACHED_HASH_CRC, 'should import MEMCACHED_HASH_CRC by :memcached_hash tag'; ok MEMCACHED_HASH_MD5(); ok MEMCACHED_HASH_CRC(); cmp_ok MEMCACHED_HASH_MD5(), '!=', MEMCACHED_HASH_CRC(); if (0) { # can't do this yet Memcached::libmemcached->import( 'LIBMEMCACHED_MAJOR_VERSION', 'LIBMEMCACHED_MAJOR_VERSION' ); ok my $lib_major_ver = LIBMEMCACHED_MAJOR_VERSION(); ok my $lib_minor_ver = LIBMEMCACHED_MAJOR_VERSION(); ok my $pm_ver = Memcached::libmemcached->VERSION; like $pm_ver, qr/^$lib_major_ver+\.$lib_minor_ver\d\d$/, "Memcached::libmemcached version should match X.YYZZ where X.YY is the libmemcached version ($lib_major_ver.$lib_minor_ver)"; } ok 1; Memcached-libmemcached-1.001801/t/27-set-cb.t0000644000175000017500000000411312522723506016701 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( memcached_set memcached_get memcached_mget memcached_mget_into_hashref ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); my $items = 2; plan tests => 21; my ($rv, $rc, $flags); my $t1= time(); my $flag_orig = 0xF000F00F; my %data = map { ("k$_.$t1" => "val$_.$t1") } (1..$items); my ($set_cb_expected_defsv, @set_cb_expected_args); my $set_cb_called = 0; my $set_cb = sub { ++$set_cb_called; print "set_cb(@_)\n"; is $_, $set_cb_expected_defsv, '$_ should be the value'; is scalar @_, 2, '@_ should be two elems: $key and $flags'; is $_[0], $set_cb_expected_args[0], 'arg 0 should be the key'; is $_[1], $set_cb_expected_args[1], 'arg 1 should be the flags'; return; }; $memc->set_callback_coderefs($set_cb, undef); print "test read-only access to values from callback\n"; for my $k (keys %data) { $set_cb_expected_defsv = $data{$k}; @set_cb_expected_args = ( $k, $flag_orig ); ok memcached_set($memc, $k, $data{$k}, 0, $flag_orig); } for my $k (keys %data) { $set_cb_expected_defsv = $data{$k}; @set_cb_expected_args = ( $k, $flag_orig ); is memcached_get($memc, $k), $data{$k}; } is $set_cb_called, scalar keys %data; $set_cb_called = 0; $memc->set_callback_coderefs(undef, sub { ++$set_cb_called; return }); my %got; ok memcached_mget_into_hashref($memc, [ keys %data ], \%got); is_deeply \%got, \%data; print "test modification of values by callback\n"; my $expected_flags = 0xE0E0E0E0; $set_cb = sub { $_ = uc($_).lc($_); $_[1] = $expected_flags; return; }; $memc->set_callback_coderefs(undef, $set_cb); for my $k (keys %data) { my $v = $data{$k}; ok memcached_set($memc, $k, $v); is memcached_get($memc, $k, my $flags), uc($v).lc($v); is $flags, $expected_flags, "flags is $flags (expected $expected_flags)" ; } Memcached-libmemcached-1.001801/t/51-flush.t0000644000175000017500000000055112522723506016644 0ustar seansean # tests for functions documented in memcached_flush.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 1; ok $memc; Memcached-libmemcached-1.001801/t/05-behavior.t0000644000175000017500000000154312522723506017323 0ustar seansean # tests for functions documented in memcached_behavior.pod use strict; use warnings; use Test::More; #$Exporter::Verbose = 1; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_behavior_get memcached_behavior_set ), # other functions and constants used by the tests qw( MEMCACHED_BEHAVIOR_TCP_NODELAY ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 6; my $rv = memcached_behavior_get($memc, MEMCACHED_BEHAVIOR_TCP_NODELAY); ok defined $rv; ok !$rv; ok memcached_behavior_set($memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); ok memcached_behavior_get($memc, MEMCACHED_BEHAVIOR_TCP_NODELAY); ok memcached_behavior_set($memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0); ok !memcached_behavior_get($memc, MEMCACHED_BEHAVIOR_TCP_NODELAY); Memcached-libmemcached-1.001801/t/31-prepend-append-by-key.t0000644000175000017500000000176712522723506021633 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_prepend_by_key memcached_append_by_key ), # other functions used by the tests qw( memcached_set_by_key memcached_get_by_key ); use lib 't/lib'; use libmemcached_test; my $pre= 'begin '; my $end= ' end'; my $m1= 'master-key'; my $k1= 'abc'; my $flags; my $rc; my $memc = libmemcached_test_create({ min_version => "1.2.4" }); plan tests => 6; my $orig = "middle"; ok memcached_set_by_key($memc, $m1, $k1, $orig); ok memcached_prepend_by_key($memc, $m1, $k1, $pre); ok memcached_append_by_key($memc, $m1, $k1, $end); my $ret= memcached_get_by_key($memc, $m1, $k1, $flags=0, $rc=0); ok $rc, 'memcached_get_by_key rc should be true'; ok defined $ret, 'memcached_get_by_key result should be defined'; my $combined= $pre . $orig . $end; cmp_ok $ret, 'eq', $combined; Memcached-libmemcached-1.001801/t/21-set-by-key.t0000644000175000017500000000103312522723506017505 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_set_by_key ), # other functions used by the tests qw( memcached_server_add memcached_create memcached_free ); use lib 't/lib'; use libmemcached_test; my $m1= 'master-key'; my $memc = libmemcached_test_create(); plan tests => 1; ok memcached_set_by_key($memc, $m1, 'abc', "this is a test"); Memcached-libmemcached-1.001801/t/pod-coverage.t0000644000175000017500000000113712522723506017654 0ustar seanseanuse strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok({ also_private => [ 'constant', qr/^MEMCACHED_/ ], }); Memcached-libmemcached-1.001801/t/lib/0000755000175000017500000000000012527462751015667 5ustar seanseanMemcached-libmemcached-1.001801/t/lib/libmemcached_test.pm0000644000175000017500000000462412522723506021660 0ustar seanseanpackage libmemcached_test; # functions to support the Memcached::libmemcached test suite use strict; use warnings; use base 'Exporter'; use Test::More; our @EXPORT = qw( libmemcached_test_create libmemcached_test_key libmemcached_version_ge libmemcached_test_servers ); use Memcached::libmemcached qw( memcached_create memcached_server_add memcached_get memcached_set memcached_errstr memcached_version ); sub libmemcached_test_servers { my $servers = $ENV{PERL_LIBMEMCACHED_TEST_SERVERS}; # XXX add the default port as well to stop uninit # warnings from the test suite $servers ||= 'localhost:11211'; return split(/\s*,\s*/, $servers); } sub libmemcached_test_create { my ($args) = @_; my $memc = memcached_create() or die "memcached_create failed"; # XXX would be good to filter this list by those we can communicate with # (and have sufficient version number) # then pick the first of those to use as the default test server my ($server,$port) = split /:/, (libmemcached_test_servers())[0]; # XXX may change to memcached_parse_options or somesuch so the env # var can set behaviours etc my $rc = memcached_server_add($memc, $server, $port); die "libmemcached_test_create: memcached_server_add($server) failed: ".memcached_errstr($memc) if not $rc; # XXX ideally this should be a much 'simpler/safer' command memcached_set($memc, "foo", "hello memcached"); plan skip_all => "Can't talk to any memcached servers" if memcached_errstr($memc) !~ /SERVER END|SUCCESS|NOT FOUND/; plan skip_all => "memcached server version less than $args->{min_version}" if $args->{min_version} && not libmemcached_version_ge($memc, $args->{min_version}); return $memc; } sub libmemcached_version_ge { my ($memc, $min_version) = @_; my @min_version = split /\./, $min_version; my @memcached_version = memcached_version($memc); for (0,1,2) { return 1 if $memcached_version[$_] > $min_version[$_]; return 0 if $memcached_version[$_] < $min_version[$_]; } return 1; # identical versions } sub libmemcached_test_key { # return a value suitable for use as a memcached key # that is unique for each run of the script # but returns the same value for the life of the script our $time_rand ||= ($^T + rand()); return $time_rand; } 1; Memcached-libmemcached-1.001801/t/lib/ExtUtils/0000755000175000017500000000000012527462751017450 5ustar seanseanMemcached-libmemcached-1.001801/t/lib/ExtUtils/ParseXS.pm0000644000175000017500000015735412522723506021343 0ustar seanseanpackage ExtUtils::ParseXS; use 5.006; # We use /??{}/ in regexes use Cwd; use Config; use File::Basename; use File::Spec; use Symbol; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(process_file); # use strict; # One of these days... my(@XSStack); # Stack of conditionals and INCLUDEs my($XSS_work_idx, $cpp_next_tmp); use vars qw($VERSION); $VERSION = '2.1801'; use vars qw(%input_expr %output_expr $ProtoUsed @InitFileCode $FH $proto_re $Overload $errors $Fallback $cplusplus $hiertype $WantPrototypes $WantVersionChk $except $WantLineNumbers $WantOptimize $process_inout $process_argtypes @tm $dir $filename $filepathname %IncludedFiles %type_kind %proto_letter %targetable $BLOCK_re $lastline $lastline_no $Package $Prefix @line @BootCode %args_match %defaults %var_types %arg_list @proto_arg $processing_arg_with_types %argtype_seen @outlist %in_out %lengthof $proto_in_this_xsub $scope_in_this_xsub $interface $prepush_done $interface_macro $interface_macro_set $ProtoThisXSUB $ScopeThisXSUB $xsreturn @line_no $ret_type $func_header $orig_args $verbose ); # Add these just to get compilation to happen. sub process_file { # Allow for $package->process_file(%hash) in the future my ($pkg, %args) = @_ % 2 ? @_ : (__PACKAGE__, @_); $ProtoUsed = exists $args{prototypes}; # Set defaults. %args = ( # 'C++' => 0, # Doesn't seem to *do* anything... hiertype => 0, except => 0, prototypes => 0, versioncheck => 1, linenumbers => 1, optimize => 1, prototypes => 0, inout => 1, argtypes => 1, typemap => [], output => \*STDOUT, csuffix => '.c', verbose => $ENV{PERL_PARSEXS_VERBOSE}||0, %args, ); # Global Constants my ($Is_VMS, $SymSet); if ($^O eq 'VMS') { $Is_VMS = 1; # Establish set of global symbols with max length 28, since xsubpp # will later add the 'XS_' prefix. require ExtUtils::XSSymSet; $SymSet = new ExtUtils::XSSymSet 28; } @XSStack = ({type => 'none'}); ($XSS_work_idx, $cpp_next_tmp) = (0, "XSubPPtmpAAAA"); @InitFileCode = (); $FH = Symbol::gensym(); $proto_re = "[" . quotemeta('\$%&*@;[]') . "]" ; $Overload = 0; $errors = 0; $Fallback = 'PL_sv_undef'; # Most of the 1500 lines below uses these globals. We'll have to # clean this up sometime, probably. For now, we just pull them out # of %args. -Ken $cplusplus = $args{'C++'}; $hiertype = $args{hiertype}; $WantPrototypes = $args{prototypes}; $WantVersionChk = $args{versioncheck}; $except = $args{except} ? ' TRY' : ''; $WantLineNumbers = $args{linenumbers}; $WantOptimize = $args{optimize}; $process_inout = $args{inout}; $process_argtypes = $args{argtypes}; $verbose = $args{verbose}; @tm = ref $args{typemap} ? @{$args{typemap}} : ($args{typemap}); for ($args{filename}) { die "Missing required parameter 'filename'" unless $_; $filepathname = $_; ($dir, $filename) = (dirname($_), basename($_)); $filepathname =~ s/\\/\\\\/g; $IncludedFiles{$_}++; } # Open the input file open($FH, $args{filename}) or die "cannot open $args{filename}: $!\n"; # Open the output file if given as a string. If they provide some # other kind of reference, trust them that we can print to it. if (not ref $args{output}) { open my($fh), "> $args{output}" or die "Can't create $args{output}: $!"; $args{outfile} = $args{output}; $args{output} = $fh; } # Really, we shouldn't have to chdir() or select() in the first # place. For now, just save & restore. my $orig_cwd = cwd(); my $orig_fh = select(); chdir($dir); my $pwd = cwd(); my $csuffix = $args{csuffix}; if ($WantLineNumbers) { my $cfile; if ( $args{outfile} ) { $cfile = $args{outfile}; } else { $cfile = $args{filename}; $cfile =~ s/\.xs$/$csuffix/i or $cfile .= $csuffix; } tie(*PSEUDO_STDOUT, 'ExtUtils::ParseXS::CountLines', $cfile, $args{output}); select PSEUDO_STDOUT; } else { select $args{output}; } foreach my $typemap (@tm) { die "Can't find $typemap in $pwd\n" unless -r $typemap; } push @tm, standard_typemap_locations(); foreach my $typemap (@tm) { next unless -f $typemap ; # skip directories, binary files etc. warn("Warning: ignoring non-text typemap file '$typemap'\n"), next unless -T $typemap ; open(TYPEMAP, $typemap) or warn ("Warning: could not open typemap file '$typemap': $!\n"), next; warn("Reading $typemap\n") if $verbose; my $mode = 'Typemap'; my $junk = "" ; my $current = \$junk; while () { next if /^\s* #/; my $line_no = $. + 1; if (/^INPUT\s*$/) { $mode = 'Input'; $current = \$junk; next; } if (/^OUTPUT\s*$/) { $mode = 'Output'; $current = \$junk; next; } if (/^TYPEMAP\s*$/) { $mode = 'Typemap'; $current = \$junk; next; } if ($mode eq 'Typemap') { chomp; my $line = $_ ; TrimWhitespace($_) ; # skip blank lines and comment lines next if /^$/ or /^#/ ; my($type,$kind, $proto) = /^\s*(.*?\S)\s+(\S+)\s*($proto_re*)\s*$/ or warn("Warning: File '$typemap' Line $. '$line' TYPEMAP entry needs 2 or 3 columns\n"), next; $type = TidyType($type) ; $type_kind{$type} = $kind ; # prototype defaults to '$' $proto = "\$" unless $proto ; warn("Warning: File '$typemap' Line $. '$line' Invalid prototype '$proto'\n") unless ValidProtoString($proto) ; $proto_letter{$type} = C_string($proto) ; } elsif (/^\s/) { $$current .= $_; } elsif ($mode eq 'Input') { s/\s+$//; $input_expr{$_} = ''; $current = \$input_expr{$_}; } else { s/\s+$//; $output_expr{$_} = ''; $current = \$output_expr{$_}; } } close(TYPEMAP); warn sprintf "typemaps: input %d, output %d\n", scalar keys %input_expr, scalar keys %output_expr if $verbose; } foreach my $key (keys %input_expr) { $input_expr{$key} =~ s/;*\s+\z//; } my ($cast, $size); our $bal = qr[(?:(?>[^()]+)|\((??{ $bal })\))*]; # ()-balanced $cast = qr[(?:\(\s*SV\s*\*\s*\)\s*)?]; # Optional (SV*) cast $size = qr[,\s* (??{ $bal }) ]x; # Third arg (to setpvn) foreach my $key (keys %output_expr) { BEGIN { $^H |= 0x00200000 }; # Equivalent to: use re 'eval', but hardcoded so we can compile re.xs my ($t, $with_size, $arg, $sarg) = ($output_expr{$key} =~ m[^ \s+ sv_set ( [iunp] ) v (n)? # Type, is_setpvn \s* \( \s* $cast \$arg \s* , \s* ( (??{ $bal }) ) # Set from ( (??{ $size }) )? # Possible sizeof set-from \) \s* ; \s* $ ]x); $targetable{$key} = [$t, $with_size, $arg, $sarg] if $t; } my $END = "!End!\n\n"; # "impossible" keyword (multiple newline) # Match an XS keyword $BLOCK_re= '\s*(' . join('|', qw( REQUIRE BOOT CASE PREINIT INPUT INIT CODE PPCODE OUTPUT CLEANUP ALIAS ATTRS PROTOTYPES PROTOTYPE VERSIONCHECK INCLUDE SCOPE INTERFACE INTERFACE_MACRO C_ARGS POSTCALL OVERLOAD FALLBACK )) . "|$END)\\s*:"; our ($C_group_rex, $C_arg); # Group in C (no support for comments or literals) $C_group_rex = qr/ [({\[] (?: (?> [^()\[\]{}]+ ) | (??{ $C_group_rex }) )* [)}\]] /x ; # Chunk in C without comma at toplevel (no comments): $C_arg = qr/ (?: (?> [^()\[\]{},"']+ ) | (??{ $C_group_rex }) | " (?: (?> [^\\"]+ ) | \\. )* " # String literal | ' (?: (?> [^\\']+ ) | \\. )* ' # Char literal )* /xs; # Identify the version of xsubpp used print <) { if (/^=/) { my $podstartline = $.; do { if (/^=cut\s*$/) { # We can't just write out a /* */ comment, as our embedded # POD might itself be in a comment. We can't put a /**/ # comment inside #if 0, as the C standard says that the source # file is decomposed into preprocessing characters in the stage # before preprocessing commands are executed. # I don't want to leave the text as barewords, because the spec # isn't clear whether macros are expanded before or after # preprocessing commands are executed, and someone pathological # may just have defined one of the 3 words as a macro that does # something strange. Multiline strings are illegal in C, so # the "" we write must be a string literal. And they aren't # concatenated until 2 steps later, so we are safe. # - Nicholas Clark print("#if 0\n \"Skipped embedded POD.\"\n#endif\n"); printf("#line %d \"$filepathname\"\n", $. + 1) if $WantLineNumbers; next firstmodule } } while (<$FH>); # At this point $. is at end of file so die won't state the start # of the problem, and as we haven't yet read any lines &death won't # show the correct line in the message either. die ("Error: Unterminated pod in $filename, line $podstartline\n") unless $lastline; } last if ($Package, $Prefix) = /^MODULE\s*=\s*[\w:]+(?:\s+PACKAGE\s*=\s*([\w:]+))?(?:\s+PREFIX\s*=\s*(\S+))?\s*$/; print $_; } unless (defined $_) { warn "Didn't find a 'MODULE ... PACKAGE ... PREFIX' line\n"; exit 0; # Not a fatal error for the caller process } print <<"EOF"; #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(var) if (0) var = var #endif EOF print 'ExtUtils::ParseXS::CountLines'->end_marker, "\n" if $WantLineNumbers; $lastline = $_; $lastline_no = $.; PARAGRAPH: while (fetch_para()) { # Print initial preprocessor statements and blank lines while (@line && $line[0] !~ /^[^\#]/) { my $line = shift(@line); print $line, "\n"; next unless $line =~ /^\#\s*((if)(?:n?def)?|elsif|else|endif)\b/; my $statement = $+; if ($statement eq 'if') { $XSS_work_idx = @XSStack; push(@XSStack, {type => 'if'}); } else { death ("Error: `$statement' with no matching `if'") if $XSStack[-1]{type} ne 'if'; if ($XSStack[-1]{varname}) { push(@InitFileCode, "#endif\n"); push(@BootCode, "#endif"); } my(@fns) = keys %{$XSStack[-1]{functions}}; if ($statement ne 'endif') { # Hide the functions defined in other #if branches, and reset. @{$XSStack[-1]{other_functions}}{@fns} = (1) x @fns; @{$XSStack[-1]}{qw(varname functions)} = ('', {}); } else { my($tmp) = pop(@XSStack); 0 while (--$XSS_work_idx && $XSStack[$XSS_work_idx]{type} ne 'if'); # Keep all new defined functions push(@fns, keys %{$tmp->{other_functions}}); @{$XSStack[$XSS_work_idx]{functions}}{@fns} = (1) x @fns; } } } next PARAGRAPH unless @line; if ($XSS_work_idx && !$XSStack[$XSS_work_idx]{varname}) { # We are inside an #if, but have not yet #defined its xsubpp variable. print "#define $cpp_next_tmp 1\n\n"; push(@InitFileCode, "#if $cpp_next_tmp\n"); push(@BootCode, "#if $cpp_next_tmp"); $XSStack[$XSS_work_idx]{varname} = $cpp_next_tmp++; } death ("Code is not inside a function" ." (maybe last function was ended by a blank line " ." followed by a statement on column one?)") if $line[0] =~ /^\s/; my ($class, $externC, $static, $elipsis, $wantRETVAL, $RETVAL_no_return); my (@fake_INPUT_pre); # For length(s) generated variables my (@fake_INPUT); # initialize info arrays undef(%args_match); undef(%var_types); undef(%defaults); undef(%arg_list) ; undef(@proto_arg) ; undef($processing_arg_with_types) ; undef(%argtype_seen) ; undef(@outlist) ; undef(%in_out) ; undef(%lengthof) ; undef($proto_in_this_xsub) ; undef($scope_in_this_xsub) ; undef($interface); undef($prepush_done); $interface_macro = 'XSINTERFACE_FUNC' ; $interface_macro_set = 'XSINTERFACE_FUNC_SET' ; $ProtoThisXSUB = $WantPrototypes ; $ScopeThisXSUB = 0; $xsreturn = 0; $_ = shift(@line); while (my $kwd = check_keyword("REQUIRE|PROTOTYPES|FALLBACK|VERSIONCHECK|INCLUDE")) { &{"${kwd}_handler"}() ; next PARAGRAPH unless @line ; $_ = shift(@line); } if (check_keyword("BOOT")) { &check_cpp; push (@BootCode, "#line $line_no[@line_no - @line] \"$filepathname\"") if $WantLineNumbers && $line[0] !~ /^\s*#\s*line\b/; push (@BootCode, @line, "") ; next PARAGRAPH ; } # extract return type, function name and arguments ($ret_type) = TidyType($_); $RETVAL_no_return = 1 if $ret_type =~ s/^NO_OUTPUT\s+//; # Allow one-line ANSI-like declaration unshift @line, $2 if $process_argtypes and $ret_type =~ s/^(.*?\w.*?)\s*\b(\w+\s*\(.*)/$1/s; warn "reading $ret_type $line[0]\n" if $verbose; # a function definition needs at least 2 lines blurt ("Error: Function definition too short '$ret_type'"), next PARAGRAPH unless @line ; $externC = 1 if $ret_type =~ s/^extern "C"\s+//; $static = 1 if $ret_type =~ s/^static\s+//; $func_header = shift(@line); blurt ("Error: Cannot parse function definition from '$func_header'"), next PARAGRAPH unless $func_header =~ /^(?:([\w:]*)::)?(\w+)\s*\(\s*(.*?)\s*\)\s*(const)?\s*(;\s*)?$/s; ($class, $func_name, $orig_args) = ($1, $2, $3) ; $class = "$4 $class" if $4; ($pname = $func_name) =~ s/^($Prefix)?/$Packprefix/; ($clean_func_name = $func_name) =~ s/^$Prefix//; $Full_func_name = "${Packid}_$clean_func_name"; if ($Is_VMS) { $Full_func_name = $SymSet->addsym($Full_func_name); } # Check for duplicate function definition for my $tmp (@XSStack) { next unless defined $tmp->{functions}{$Full_func_name}; Warn("Warning: duplicate function definition '$clean_func_name' detected"); last; } $XSStack[$XSS_work_idx]{functions}{$Full_func_name} ++ ; %XsubAliases = %XsubAliasValues = %Interfaces = @Attributes = (); $DoSetMagic = 1; $orig_args =~ s/\\\s*/ /g; # process line continuations my @args; my %only_C_inlist; # Not in the signature of Perl function if ($process_argtypes and $orig_args =~ /\S/) { my $args = "$orig_args ,"; if ($args =~ /^( (??{ $C_arg }) , )* $ /x) { @args = ($args =~ /\G ( (??{ $C_arg }) ) , /xg); for ( @args ) { s/^\s+//; s/\s+$//; my ($arg, $default) = / ( [^=]* ) ( (?: = .* )? ) /x; my ($pre, $name) = ($arg =~ /(.*?) \s* \b ( \w+ | (?:byte\s+|utf8\s+)? length\( \s*\w+\s* \) ) \s* $ /x); next unless defined($pre) && length($pre); my $out_type = ''; my $inout_var; if ($process_inout and s/^(IN|IN_OUTLIST|OUTLIST|OUT|IN_OUT)\s+//) { my $type = $1; $out_type = $type if $type ne 'IN'; $arg =~ s/^(IN|IN_OUTLIST|OUTLIST|OUT|IN_OUT)\s+//; $pre =~ s/^(IN|IN_OUTLIST|OUTLIST|OUT|IN_OUT)\s+//; } my $islength; if ($name =~ /^(?:byte\s+|utf8\s+)? length \( \s* (\w+) \s* \)\z/x) { $name = "XSauto_length_of_$1"; $islength = 1; die "Default value on length() argument: `$_'" if length $default; } if (length $pre or $islength) { # Has a type if ($islength) { push @fake_INPUT_pre, $arg; } else { push @fake_INPUT, $arg; } # warn "pushing '$arg'\n"; $argtype_seen{$name}++; $_ = "$name$default"; # Assigns to @args } $only_C_inlist{$_} = 1 if $out_type eq "OUTLIST" or $islength; push @outlist, $name if $out_type =~ /OUTLIST$/; $in_out{$name} = $out_type if $out_type; } } else { @args = split(/\s*,\s*/, $orig_args); Warn("Warning: cannot parse argument list '$orig_args', fallback to split"); } } else { @args = split(/\s*,\s*/, $orig_args); for (@args) { if ($process_inout and s/^(IN|IN_OUTLIST|OUTLIST|IN_OUT|OUT)\s+//) { my $out_type = $1; next if $out_type eq 'IN'; $only_C_inlist{$_} = 1 if $out_type eq "OUTLIST"; push @outlist, $name if $out_type =~ /OUTLIST$/; $in_out{$_} = $out_type; } } } if (defined($class)) { my $arg0 = ((defined($static) or $func_name eq 'new') ? "CLASS" : "THIS"); unshift(@args, $arg0); ($report_args = "$arg0, $report_args") =~ s/^\w+, $/$arg0/; } my $extra_args = 0; @args_num = (); $num_args = 0; my $report_args = ''; foreach my $i (0 .. $#args) { if ($args[$i] =~ s/\.\.\.//) { $elipsis = 1; if ($args[$i] eq '' && $i == $#args) { $report_args .= ", ..."; pop(@args); last; } } if ($only_C_inlist{$args[$i]}) { push @args_num, undef; } else { push @args_num, ++$num_args; $report_args .= ", $args[$i]"; } if ($args[$i] =~ /^([^=]*[^\s=])\s*=\s*(.*)/s) { $extra_args++; $args[$i] = $1; $defaults{$args[$i]} = $2; $defaults{$args[$i]} =~ s/"/\\"/g; } $proto_arg[$i+1] = '$' ; } $min_args = $num_args - $extra_args; $report_args =~ s/"/\\"/g; $report_args =~ s/^,\s+//; my @func_args = @args; shift @func_args if defined($class); for (@func_args) { s/^/&/ if $in_out{$_}; } $func_args = join(", ", @func_args); @args_match{@args} = @args_num; $PPCODE = grep(/^\s*PPCODE\s*:/, @line); $CODE = grep(/^\s*CODE\s*:/, @line); # Detect CODE: blocks which use ST(n)= or XST_m*(n,v) # to set explicit return values. $EXPLICIT_RETURN = ($CODE && ("@line" =~ /(\bST\s*\([^;]*=) | (\bXST_m\w+\s*\()/x )); $ALIAS = grep(/^\s*ALIAS\s*:/, @line); $INTERFACE = grep(/^\s*INTERFACE\s*:/, @line); $xsreturn = 1 if $EXPLICIT_RETURN; $externC = $externC ? qq[extern "C"] : ""; # print function header print Q(<<"EOF"); #$externC #XS(XS_${Full_func_name}); /* prototype to pass -Wmissing-prototypes */ #XS(XS_${Full_func_name}) #[[ ##ifdef dVAR # dVAR; dXSARGS; ##else # dXSARGS; ##endif EOF print Q(<<"EOF") if $ALIAS ; # dXSI32; EOF print Q(<<"EOF") if $INTERFACE ; # dXSFUNCTION($ret_type); EOF if ($elipsis) { $cond = ($min_args ? qq(items < $min_args) : 0); } elsif ($min_args == $num_args) { $cond = qq(items != $min_args); } else { $cond = qq(items < $min_args || items > $num_args); } print Q(<<"EOF") if $except; # char errbuf[1024]; # *errbuf = '\0'; EOF if ($ALIAS) { print Q(<<"EOF") if $cond } # if ($cond) # Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "$report_args"); EOF else { print Q(<<"EOF") if $cond } # if ($cond) # Perl_croak(aTHX_ "Usage: %s(%s)", "$pname", "$report_args"); EOF # cv doesn't seem to be used, in most cases unless we go in # the if of this else print Q(<<"EOF"); # PERL_UNUSED_VAR(cv); /* -W */ EOF #gcc -Wall: if an xsub has PPCODE is used #it is possible none of ST, XSRETURN or XSprePUSH macros are used #hence `ax' (setup by dXSARGS) is unused #XXX: could breakup the dXSARGS; into dSP;dMARK;dITEMS #but such a move could break third-party extensions print Q(<<"EOF") if $PPCODE; # PERL_UNUSED_VAR(ax); /* -Wall */ EOF print Q(<<"EOF") if $PPCODE; # SP -= items; EOF # Now do a block of some sort. $condnum = 0; $cond = ''; # last CASE: condidional push(@line, "$END:"); push(@line_no, $line_no[-1]); $_ = ''; &check_cpp; while (@line) { &CASE_handler if check_keyword("CASE"); print Q(<<"EOF"); # $except [[ EOF # do initialization of input variables $thisdone = 0; $retvaldone = 0; %deferred; %arg_list = () ; $gotRETVAL = 0; INPUT_handler() ; process_keyword("INPUT|PREINIT|INTERFACE_MACRO|C_ARGS|ALIAS|ATTRS|PROTOTYPE|SCOPE|OVERLOAD") ; print Q(<<"EOF") if $ScopeThisXSUB; # ENTER; # [[ EOF if (!$thisdone && defined($class)) { if (defined($static) or $func_name eq 'new') { print "\tchar *"; $var_types{"CLASS"} = "char *"; &generate_init("char *", 1, "CLASS"); } else { print "\t$class *"; $var_types{"THIS"} = "$class *"; &generate_init("$class *", 1, "THIS"); } } # do code if (/^\s*NOT_IMPLEMENTED_YET/) { print "\n\tPerl_croak(aTHX_ \"$pname: not implemented yet\");\n"; $_ = '' ; } else { if ($ret_type ne "void") { print "\t" . &map_type($ret_type, 'RETVAL') . ";\n" if !$retvaldone; $args_match{"RETVAL"} = 0; $var_types{"RETVAL"} = $ret_type; print "\tdXSTARG;\n" if $WantOptimize and $targetable{$type_kind{$ret_type}}; } if (@fake_INPUT or @fake_INPUT_pre) { unshift @line, @fake_INPUT_pre, @fake_INPUT, $_; $_ = ""; $processing_arg_with_types = 1; INPUT_handler() ; } print delete $deferred{post_input}; process_keyword("INIT|ALIAS|ATTRS|PROTOTYPE|INTERFACE_MACRO|INTERFACE|C_ARGS|OVERLOAD") ; print delete $deferred{pre_call}; print delete $deferred{auto_length_init}; if (check_keyword("PPCODE")) { print_section(); death ("PPCODE must be last thing") if @line; print "\tLEAVE;\n" if $ScopeThisXSUB; print "\tPUTBACK;\n\treturn;\n"; } elsif (check_keyword("CODE")) { print_section() ; } elsif (defined($class) and $func_name eq "DESTROY") { print "\n\t"; print "delete THIS;\n"; } else { print "\n\t"; if ($ret_type ne "void") { print "RETVAL = "; $wantRETVAL = 1; } if (defined($static)) { if ($func_name eq 'new') { $func_name = "$class"; } else { print "${class}::"; } } elsif (defined($class)) { if ($func_name eq 'new') { $func_name .= " $class"; } else { print "THIS->"; } } $func_name =~ s/^\Q$args{'s'}// if exists $args{'s'}; $func_name = 'XSFUNCTION' if $interface; print "$func_name($func_args);\n"; } } # do output variables $gotRETVAL = 0; # 1 if RETVAL seen in OUTPUT section; undef $RETVAL_code ; # code to set RETVAL (from OUTPUT section); # $wantRETVAL set if 'RETVAL =' autogenerated ($wantRETVAL, $ret_type) = (0, 'void') if $RETVAL_no_return; undef %outargs ; process_keyword("POSTCALL|OUTPUT|ALIAS|ATTRS|PROTOTYPE|OVERLOAD"); &generate_output($var_types{$_}, $args_match{$_}, $_, $DoSetMagic) for grep $in_out{$_} =~ /OUT$/, keys %in_out; # all OUTPUT done, so now push the return value on the stack if ($gotRETVAL && $RETVAL_code) { print "\t$RETVAL_code\n"; } elsif ($gotRETVAL || $wantRETVAL) { my $t = $WantOptimize && $targetable{$type_kind{$ret_type}}; my $var = 'RETVAL'; my $type = $ret_type; # 0: type, 1: with_size, 2: how, 3: how_size if ($t and not $t->[1] and $t->[0] eq 'p') { # PUSHp corresponds to setpvn. Treate setpv directly my $what = eval qq("$t->[2]"); warn $@ if $@; print "\tsv_setpv(TARG, $what); XSprePUSH; PUSHTARG;\n"; $prepush_done = 1; } elsif ($t) { my $what = eval qq("$t->[2]"); warn $@ if $@; my $size = $t->[3]; $size = '' unless defined $size; $size = eval qq("$size"); warn $@ if $@; print "\tXSprePUSH; PUSH$t->[0]($what$size);\n"; $prepush_done = 1; } else { # RETVAL almost never needs SvSETMAGIC() &generate_output($ret_type, 0, 'RETVAL', 0); } } $xsreturn = 1 if $ret_type ne "void"; my $num = $xsreturn; my $c = @outlist; print "\tXSprePUSH;" if $c and not $prepush_done; print "\tEXTEND(SP,$c);\n" if $c; $xsreturn += $c; generate_output($var_types{$_}, $num++, $_, 0, 1) for @outlist; # do cleanup process_keyword("CLEANUP|ALIAS|ATTRS|PROTOTYPE|OVERLOAD") ; print Q(<<"EOF") if $ScopeThisXSUB; # ]] EOF print Q(<<"EOF") if $ScopeThisXSUB and not $PPCODE; # LEAVE; EOF # print function trailer print Q(<<"EOF"); # ]] EOF print Q(<<"EOF") if $except; # BEGHANDLERS # CATCHALL # sprintf(errbuf, "%s: %s\\tpropagated", Xname, Xreason); # ENDHANDLERS EOF if (check_keyword("CASE")) { blurt ("Error: No `CASE:' at top of function") unless $condnum; $_ = "CASE: $_"; # Restore CASE: label next; } last if $_ eq "$END:"; death(/^$BLOCK_re/o ? "Misplaced `$1:'" : "Junk at end of function"); warn "internal error: deferred '$_' not consumed\n" for keys %deferred; } print Q(<<"EOF") if $except; # if (errbuf[0]) # Perl_croak(aTHX_ errbuf); EOF if ($xsreturn) { print Q(<<"EOF") unless $PPCODE; # XSRETURN($xsreturn); EOF } else { print Q(<<"EOF") unless $PPCODE; # XSRETURN_EMPTY; EOF } print Q(<<"EOF"); #]] # EOF my $newXS = "newXS" ; my $proto = "" ; # Build the prototype string for the xsub if ($ProtoThisXSUB) { $newXS = "newXSproto"; if ($ProtoThisXSUB eq 2) { # User has specified empty prototype } elsif ($ProtoThisXSUB eq 1) { my $s = ';'; if ($min_args < $num_args) { $s = ''; $proto_arg[$min_args] .= ";" ; } push @proto_arg, "$s\@" if $elipsis ; $proto = join ("", grep defined, @proto_arg); } else { # User has specified a prototype $proto = $ProtoThisXSUB; } $proto = qq{, "$proto"}; } if (%XsubAliases) { $XsubAliases{$pname} = 0 unless defined $XsubAliases{$pname} ; while ( ($name, $value) = each %XsubAliases) { push(@InitFileCode, Q(<<"EOF")); # cv = newXS(\"$name\", XS_$Full_func_name, file); # XSANY.any_i32 = $value ; EOF push(@InitFileCode, Q(<<"EOF")) if $proto; # sv_setpv((SV*)cv$proto) ; EOF } } elsif (@Attributes) { push(@InitFileCode, Q(<<"EOF")); # cv = newXS(\"$pname\", XS_$Full_func_name, file); # apply_attrs_string("$Package", cv, "@Attributes", 0); EOF } elsif ($interface) { while ( ($name, $value) = each %Interfaces) { $name = "$Package\::$name" unless $name =~ /::/; push(@InitFileCode, Q(<<"EOF")); # cv = newXS(\"$name\", XS_$Full_func_name, file); # $interface_macro_set(cv,$value) ; EOF push(@InitFileCode, Q(<<"EOF")) if $proto; # sv_setpv((SV*)cv$proto) ; EOF } } else { push(@InitFileCode, " ${newXS}(\"$pname\", XS_$Full_func_name, file$proto);\n"); } } warn "Writing bootstrap code\n" if $verbose; if ($Overload) # make it findable with fetchmethod { print Q(<<"EOF"); #XS(XS_${Packid}_nil); /* prototype to pass -Wmissing-prototypes */ #XS(XS_${Packid}_nil) #{ # XSRETURN_EMPTY; #} # EOF unshift(@InitFileCode, <<"MAKE_FETCHMETHOD_WORK"); /* Making a sub named "${Package}::()" allows the package */ /* to be findable via fetchmethod(), and causes */ /* overload::Overloaded("${Package}") to return true. */ newXS("${Package}::()", XS_${Packid}_nil, file$proto); MAKE_FETCHMETHOD_WORK } # print initialization routine print Q(<<"EOF"); ##ifdef __cplusplus #extern "C" ##endif EOF print Q(<<"EOF"); #XS(boot_$Module_cname); /* prototype to pass -Wmissing-prototypes */ #XS(boot_$Module_cname) EOF print Q(<<"EOF"); #[[ ##ifdef dVAR # dVAR; dXSARGS; ##else # dXSARGS; ##endif EOF #-Wall: if there is no $Full_func_name there are no xsubs in this .xs #so `file' is unused print Q(<<"EOF") if $Full_func_name; # char* file = __FILE__; EOF print Q("#\n"); print Q(<<"EOF"); # PERL_UNUSED_VAR(cv); /* -W */ # PERL_UNUSED_VAR(items); /* -W */ EOF print Q(<<"EOF") if $WantVersionChk ; # XS_VERSION_BOOTCHECK ; # EOF print Q(<<"EOF") if defined $XsubAliases or defined $Interfaces ; # { # CV * cv ; # EOF print Q(<<"EOF") if ($Overload); # /* register the overloading (type 'A') magic */ # PL_amagic_generation++; # /* The magic for overload gets a GV* via gv_fetchmeth as */ # /* mentioned above, and looks in the SV* slot of it for */ # /* the "fallback" status. */ # sv_setsv( # get_sv( "${Package}::()", TRUE ), # $Fallback # ); EOF print @InitFileCode; print Q(<<"EOF") if defined $XsubAliases or defined $Interfaces ; # } EOF if (@BootCode) { print "\n /* Initialisation Section */\n\n" ; @line = @BootCode; print_section(); print "\n /* End of Initialisation Section */\n\n" ; } if ($] >= 5.009) { print <<'EOF'; if (PL_unitcheckav) call_list(PL_scopestack_ix, PL_unitcheckav); EOF } print Q(<<"EOF"); # XSRETURN_YES; #]] # EOF warn("Please specify prototyping behavior for $filename (see perlxs manual)\n") unless $ProtoUsed ; chdir($orig_cwd); select($orig_fh); untie *PSEUDO_STDOUT if tied *PSEUDO_STDOUT; close $FH; return 1; } sub errors { $errors } sub standard_typemap_locations { # Add all the default typemap locations to the search path my @tm = qw(typemap); my $updir = File::Spec->updir; foreach my $dir (File::Spec->catdir(($updir) x 1), File::Spec->catdir(($updir) x 2), File::Spec->catdir(($updir) x 3), File::Spec->catdir(($updir) x 4)) { unshift @tm, File::Spec->catfile($dir, 'typemap'); unshift @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap'); } foreach my $dir (@INC) { my $file = File::Spec->catfile($dir, ExtUtils => 'typemap'); unshift @tm, $file if -e $file; } return @tm; } sub TrimWhitespace { $_[0] =~ s/^\s+|\s+$//go ; } sub TidyType { local ($_) = @_ ; # rationalise any '*' by joining them into bunches and removing whitespace s#\s*(\*+)\s*#$1#g; s#(\*+)# $1 #g ; # change multiple whitespace into a single space s/\s+/ /g ; # trim leading & trailing whitespace TrimWhitespace($_) ; $_ ; } # Input: ($_, @line) == unparsed input. # Output: ($_, @line) == (rest of line, following lines). # Return: the matched keyword if found, otherwise 0 sub check_keyword { $_ = shift(@line) while !/\S/ && @line; my $keyword = s/^(\s*)($_[0])\s*:\s*(?:#.*)?/$1/s && $2; warn "\t$keyword\n" if $keyword && $verbose; return $keyword; } sub print_section { # the "do" is required for right semantics do { $_ = shift(@line) } while !/\S/ && @line; print("#line ", $line_no[@line_no - @line -1], " \"$filepathname\"\n") if $WantLineNumbers && !/^\s*#\s*line\b/ && !/^#if XSubPPtmp/; for (; defined($_) && !/^$BLOCK_re/o; $_ = shift(@line)) { print "$_\n"; } print 'ExtUtils::ParseXS::CountLines'->end_marker, "\n" if $WantLineNumbers; } sub merge_section { my $in = ''; while (!/\S/ && @line) { $_ = shift(@line); } for (; defined($_) && !/^$BLOCK_re/o; $_ = shift(@line)) { $in .= "$_\n"; } chomp $in; return $in; } sub process_keyword($) { my($pattern) = @_ ; my $kwd ; &{"${kwd}_handler"}() while $kwd = check_keyword($pattern) ; } sub CASE_handler { blurt ("Error: `CASE:' after unconditional `CASE:'") if $condnum && $cond eq ''; $cond = $_; TrimWhitespace($cond); print " ", ($condnum++ ? " else" : ""), ($cond ? " if ($cond)\n" : "\n"); $_ = '' ; } sub INPUT_handler { for (; !/^$BLOCK_re/o; $_ = shift(@line)) { last if /^\s*NOT_IMPLEMENTED_YET/; next unless /\S/; # skip blank lines TrimWhitespace($_) ; my $line = $_ ; # remove trailing semicolon if no initialisation s/\s*;$//g unless /[=;+].*\S/ ; # Process the length(foo) declarations if (s/^([^=]*?) (\b byte|\b utf8|) \s+ length \(\s*(\w+)\s*\)\s*$/$1 XSauto_length_of_$3=NO_INIT/x) { my $length_var = "STRLEN_length_of_$3"; $lengthof{$3} = [ $2, $length_var, $3 ]; # '' or 'byte' or 'utf8' print "\tSTRLEN\t$length_var;\n"; $deferred{auto_length_init} .= "\tXSauto_length_of_$3 = $length_var;\n"; } # check for optional initialisation code my $var_init = '' ; $var_init = $1 if s/\s*([=;+].*)$//s ; $var_init =~ s/"/\\"/g; s/\s+/ /g; my ($var_type, $var_addr, $var_name) = /^(.*?[^&\s])\s*(\&?)\s*\b(\w+)$/s or blurt("Error: invalid argument declaration '$line'"), next; # Check for duplicate definitions blurt ("Error: duplicate definition of argument '$var_name' ignored"), next if $arg_list{$var_name}++ or defined $argtype_seen{$var_name} and not $processing_arg_with_types; $thisdone |= $var_name eq "THIS"; $retvaldone |= $var_name eq "RETVAL"; $var_types{$var_name} = $var_type; # XXXX This check is a safeguard against the unfinished conversion of # generate_init(). When generate_init() is fixed, # one can use 2-args map_type() unconditionally. if ($var_type =~ / \( \s* \* \s* \) /x) { # Function pointers are not yet supported with &output_init! print "\t" . &map_type($var_type, $var_name); $name_printed = 1; } else { print "\t" . &map_type($var_type); $name_printed = 0; } $var_num = $args_match{$var_name}; $proto_arg[$var_num] = ProtoString($var_type) if $var_num ; $func_args =~ s/\b($var_name)\b/&$1/ if $var_addr; if ($var_init =~ /^[=;]\s*NO_INIT\s*;?\s*$/ or $in_out{$var_name} and $in_out{$var_name} =~ /^OUT/ and $var_init !~ /\S/) { if ($name_printed) { print ";\n"; } else { print "\t$var_name;\n"; } } elsif ($var_init =~ /\S/) { &output_init($var_type, $var_num, $var_name, $var_init, $name_printed); } elsif ($var_num) { # generate initialization code &generate_init($var_type, $var_num, $var_name, $name_printed); } else { print ";\n"; } } } sub OUTPUT_handler { for (; !/^$BLOCK_re/o; $_ = shift(@line)) { next unless /\S/; if (/^\s*SETMAGIC\s*:\s*(ENABLE|DISABLE)\s*/) { $DoSetMagic = ($1 eq "ENABLE" ? 1 : 0); next; } my ($outarg, $outcode) = /^\s*(\S+)\s*(.*?)\s*$/s ; blurt ("Error: duplicate OUTPUT argument '$outarg' ignored"), next if $outargs{$outarg} ++ ; if (!$gotRETVAL and $outarg eq 'RETVAL') { # deal with RETVAL last $RETVAL_code = $outcode ; $gotRETVAL = 1 ; next ; } blurt ("Error: OUTPUT $outarg not an argument"), next unless defined($args_match{$outarg}); blurt("Error: No input definition for OUTPUT argument '$outarg' - ignored"), next unless defined $var_types{$outarg} ; $var_num = $args_match{$outarg}; if ($outcode) { print "\t$outcode\n"; print "\tSvSETMAGIC(ST(" , $var_num-1 , "));\n" if $DoSetMagic; } else { &generate_output($var_types{$outarg}, $var_num, $outarg, $DoSetMagic); } delete $in_out{$outarg} # No need to auto-OUTPUT if exists $in_out{$outarg} and $in_out{$outarg} =~ /OUT$/; } } sub C_ARGS_handler() { my $in = merge_section(); TrimWhitespace($in); $func_args = $in; } sub INTERFACE_MACRO_handler() { my $in = merge_section(); TrimWhitespace($in); if ($in =~ /\s/) { # two ($interface_macro, $interface_macro_set) = split ' ', $in; } else { $interface_macro = $in; $interface_macro_set = 'UNKNOWN_CVT'; # catch later } $interface = 1; # local $Interfaces = 1; # global } sub INTERFACE_handler() { my $in = merge_section(); TrimWhitespace($in); foreach (split /[\s,]+/, $in) { my $name = $_; $name =~ s/^$Prefix//; $Interfaces{$name} = $_; } print Q(<<"EOF"); # XSFUNCTION = $interface_macro($ret_type,cv,XSANY.any_dptr); EOF $interface = 1; # local $Interfaces = 1; # global } sub CLEANUP_handler() { print_section() } sub PREINIT_handler() { print_section() } sub POSTCALL_handler() { print_section() } sub INIT_handler() { print_section() } sub GetAliases { my ($line) = @_ ; my ($orig) = $line ; my ($alias) ; my ($value) ; # Parse alias definitions # format is # alias = value alias = value ... while ($line =~ s/^\s*([\w:]+)\s*=\s*(\w+)\s*//) { $alias = $1 ; $orig_alias = $alias ; $value = $2 ; # check for optional package definition in the alias $alias = $Packprefix . $alias if $alias !~ /::/ ; # check for duplicate alias name & duplicate value Warn("Warning: Ignoring duplicate alias '$orig_alias'") if defined $XsubAliases{$alias} ; Warn("Warning: Aliases '$orig_alias' and '$XsubAliasValues{$value}' have identical values") if $XsubAliasValues{$value} ; $XsubAliases = 1; $XsubAliases{$alias} = $value ; $XsubAliasValues{$value} = $orig_alias ; } blurt("Error: Cannot parse ALIAS definitions from '$orig'") if $line ; } sub ATTRS_handler () { for (; !/^$BLOCK_re/o; $_ = shift(@line)) { next unless /\S/; TrimWhitespace($_) ; push @Attributes, $_; } } sub ALIAS_handler () { for (; !/^$BLOCK_re/o; $_ = shift(@line)) { next unless /\S/; TrimWhitespace($_) ; GetAliases($_) if $_ ; } } sub OVERLOAD_handler() { for (; !/^$BLOCK_re/o; $_ = shift(@line)) { next unless /\S/; TrimWhitespace($_) ; while ( s/^\s*([\w:"\\)\+\-\*\/\%\<\>\.\&\|\^\!\~\{\}\=]+)\s*//) { $Overload = 1 unless $Overload; my $overload = "$Package\::(".$1 ; push(@InitFileCode, " newXS(\"$overload\", XS_$Full_func_name, file$proto);\n"); } } } sub FALLBACK_handler() { # the rest of the current line should contain either TRUE, # FALSE or UNDEF TrimWhitespace($_) ; my %map = ( TRUE => "PL_sv_yes", 1 => "PL_sv_yes", FALSE => "PL_sv_no", 0 => "PL_sv_no", UNDEF => "PL_sv_undef", ) ; # check for valid FALLBACK value death ("Error: FALLBACK: TRUE/FALSE/UNDEF") unless exists $map{uc $_} ; $Fallback = $map{uc $_} ; } sub REQUIRE_handler () { # the rest of the current line should contain a version number my ($Ver) = $_ ; TrimWhitespace($Ver) ; death ("Error: REQUIRE expects a version number") unless $Ver ; # check that the version number is of the form n.n death ("Error: REQUIRE: expected a number, got '$Ver'") unless $Ver =~ /^\d+(\.\d*)?/ ; death ("Error: xsubpp $Ver (or better) required--this is only $VERSION.") unless $VERSION >= $Ver ; } sub VERSIONCHECK_handler () { # the rest of the current line should contain either ENABLE or # DISABLE TrimWhitespace($_) ; # check for ENABLE/DISABLE death ("Error: VERSIONCHECK: ENABLE/DISABLE") unless /^(ENABLE|DISABLE)/i ; $WantVersionChk = 1 if $1 eq 'ENABLE' ; $WantVersionChk = 0 if $1 eq 'DISABLE' ; } sub PROTOTYPE_handler () { my $specified ; death("Error: Only 1 PROTOTYPE definition allowed per xsub") if $proto_in_this_xsub ++ ; for (; !/^$BLOCK_re/o; $_ = shift(@line)) { next unless /\S/; $specified = 1 ; TrimWhitespace($_) ; if ($_ eq 'DISABLE') { $ProtoThisXSUB = 0 } elsif ($_ eq 'ENABLE') { $ProtoThisXSUB = 1 } else { # remove any whitespace s/\s+//g ; death("Error: Invalid prototype '$_'") unless ValidProtoString($_) ; $ProtoThisXSUB = C_string($_) ; } } # If no prototype specified, then assume empty prototype "" $ProtoThisXSUB = 2 unless $specified ; $ProtoUsed = 1 ; } sub SCOPE_handler () { death("Error: Only 1 SCOPE declaration allowed per xsub") if $scope_in_this_xsub ++ ; for (; !/^$BLOCK_re/o; $_ = shift(@line)) { next unless /\S/; TrimWhitespace($_) ; if ($_ =~ /^DISABLE/i) { $ScopeThisXSUB = 0 } elsif ($_ =~ /^ENABLE/i) { $ScopeThisXSUB = 1 } } } sub PROTOTYPES_handler () { # the rest of the current line should contain either ENABLE or # DISABLE TrimWhitespace($_) ; # check for ENABLE/DISABLE death ("Error: PROTOTYPES: ENABLE/DISABLE") unless /^(ENABLE|DISABLE)/i ; $WantPrototypes = 1 if $1 eq 'ENABLE' ; $WantPrototypes = 0 if $1 eq 'DISABLE' ; $ProtoUsed = 1 ; } sub INCLUDE_handler () { # the rest of the current line should contain a valid filename TrimWhitespace($_) ; death("INCLUDE: filename missing") unless $_ ; death("INCLUDE: output pipe is illegal") if /^\s*\|/ ; # simple minded recursion detector death("INCLUDE loop detected") if $IncludedFiles{$_} ; ++ $IncludedFiles{$_} unless /\|\s*$/ ; # Save the current file context. push(@XSStack, { type => 'file', LastLine => $lastline, LastLineNo => $lastline_no, Line => \@line, LineNo => \@line_no, Filename => $filename, Filepathname => $filepathname, Handle => $FH, }) ; $FH = Symbol::gensym(); # open the new file open ($FH, "$_") or death("Cannot open '$_': $!") ; print Q(<<"EOF"); # #/* INCLUDE: Including '$_' from '$filename' */ # EOF $filepathname = $filename = $_ ; # Prime the pump by reading the first # non-blank line # skip leading blank lines while (<$FH>) { last unless /^\s*$/ ; } $lastline = $_ ; $lastline_no = $. ; } sub PopFile() { return 0 unless $XSStack[-1]{type} eq 'file' ; my $data = pop @XSStack ; my $ThisFile = $filename ; my $isPipe = ($filename =~ /\|\s*$/) ; -- $IncludedFiles{$filename} unless $isPipe ; close $FH ; $FH = $data->{Handle} ; # $filename is the leafname, which for some reason isused for diagnostic # messages, whereas $filepathname is the full pathname, and is used for # #line directives. $filename = $data->{Filename} ; $filepathname = $data->{Filepathname} ; $lastline = $data->{LastLine} ; $lastline_no = $data->{LastLineNo} ; @line = @{ $data->{Line} } ; @line_no = @{ $data->{LineNo} } ; if ($isPipe and $? ) { -- $lastline_no ; print STDERR "Error reading from pipe '$ThisFile': $! in $filename, line $lastline_no\n" ; exit 1 ; } print Q(<<"EOF"); # #/* INCLUDE: Returning to '$filename' from '$ThisFile' */ # EOF return 1 ; } sub ValidProtoString ($) { my($string) = @_ ; if ( $string =~ /^$proto_re+$/ ) { return $string ; } return 0 ; } sub C_string ($) { my($string) = @_ ; $string =~ s[\\][\\\\]g ; $string ; } sub ProtoString ($) { my ($type) = @_ ; $proto_letter{$type} or "\$" ; } sub check_cpp { my @cpp = grep(/^\#\s*(?:if|e\w+)/, @line); if (@cpp) { my ($cpp, $cpplevel); for $cpp (@cpp) { if ($cpp =~ /^\#\s*if/) { $cpplevel++; } elsif (!$cpplevel) { Warn("Warning: #else/elif/endif without #if in this function"); print STDERR " (precede it with a blank line if the matching #if is outside the function)\n" if $XSStack[-1]{type} eq 'if'; return; } elsif ($cpp =~ /^\#\s*endif/) { $cpplevel--; } } Warn("Warning: #if without #endif in this function") if $cpplevel; } } sub Q { my($text) = @_; $text =~ s/^#//gm; $text =~ s/\[\[/{/g; $text =~ s/\]\]/}/g; $text; } # Read next xsub into @line from ($lastline, <$FH>). sub fetch_para { # parse paragraph death ("Error: Unterminated `#if/#ifdef/#ifndef'") if !defined $lastline && $XSStack[-1]{type} eq 'if'; @line = (); @line_no = () ; return PopFile() if !defined $lastline; if ($lastline =~ /^MODULE\s*=\s*([\w:]+)(?:\s+PACKAGE\s*=\s*([\w:]+))?(?:\s+PREFIX\s*=\s*(\S+))?\s*$/) { $Module = $1; $Package = defined($2) ? $2 : ''; # keep -w happy $Prefix = defined($3) ? $3 : ''; # keep -w happy $Prefix = quotemeta $Prefix ; ($Module_cname = $Module) =~ s/\W/_/g; ($Packid = $Package) =~ tr/:/_/; $Packprefix = $Package; $Packprefix .= "::" if $Packprefix ne ""; $lastline = ""; } for (;;) { # Skip embedded PODs while ($lastline =~ /^=/) { while ($lastline = <$FH>) { last if ($lastline =~ /^=cut\s*$/); } death ("Error: Unterminated pod") unless $lastline; $lastline = <$FH>; chomp $lastline; $lastline =~ s/^\s+$//; } if ($lastline !~ /^\s*#/ || # CPP directives: # ANSI: if ifdef ifndef elif else endif define undef # line error pragma # gcc: warning include_next # obj-c: import # others: ident (gcc notes that some cpps have this one) $lastline =~ /^#[ \t]*(?:(?:if|ifn?def|elif|else|endif|define|undef|pragma|error|warning|line\s+\d+|ident)\b|(?:include(?:_next)?|import)\s*["<].*[>"])/) { last if $lastline =~ /^\S/ && @line && $line[-1] eq ""; push(@line, $lastline); push(@line_no, $lastline_no) ; } # Read next line and continuation lines last unless defined($lastline = <$FH>); $lastline_no = $.; my $tmp_line; $lastline .= $tmp_line while ($lastline =~ /\\$/ && defined($tmp_line = <$FH>)); chomp $lastline; $lastline =~ s/^\s+$//; } pop(@line), pop(@line_no) while @line && $line[-1] eq ""; 1; } sub output_init { local($type, $num, $var, $init, $name_printed) = @_; local($arg) = "ST(" . ($num - 1) . ")"; if ( $init =~ /^=/ ) { if ($name_printed) { eval qq/print " $init\\n"/; } else { eval qq/print "\\t$var $init\\n"/; } warn $@ if $@; } else { if ( $init =~ s/^\+// && $num ) { &generate_init($type, $num, $var, $name_printed); } elsif ($name_printed) { print ";\n"; $init =~ s/^;//; } else { eval qq/print "\\t$var;\\n"/; warn $@ if $@; $init =~ s/^;//; } $deferred{post_input} .= eval qq/"\\n\\t$init\\n"/; warn $@ if $@; } } sub Warn { # work out the line number my $line_no = $line_no[@line_no - @line -1] ; print STDERR "@_ in $filename, line $line_no\n" ; } sub blurt { Warn @_ ; $errors ++ } sub death { Warn @_ ; exit 1 ; } sub generate_init { local($type, $num, $var) = @_; local($arg) = "ST(" . ($num - 1) . ")"; local($argoff) = $num - 1; local($ntype); local($tk); local($length_var); # name of STRLEN C var to use if $lengthof{$var} is true $type = TidyType($type) ; blurt("Error: '$type' not in typemap"), return unless defined($type_kind{$type}); ($ntype = $type) =~ s/\s*\*/Ptr/g; ($subtype = $ntype) =~ s/(?:Array)?(?:Ptr)?$//; $tk = $type_kind{$type}; $tk =~ s/OBJ$/REF/ if $func_name =~ /DESTROY$/; $type =~ tr/:/_/ unless $hiertype; $expr = $input_expr{$tk}; blurt("Error: No INPUT definition for type '$type', typekind '$type_kind{$type}' found"), return unless defined $expr; if ($lengthof{$var}) { # encoding is '' or 'byte' or 'utf8' (my $encoding, $length_var, my $related_var) = @{ $lengthof{$var} }; if ($tk eq 'T_PV') { # hardwired support for plain T_PV (char *) print "\t$var" unless $name_printed; print " = ($type)SvPV$encoding($arg, $length_var);\n"; die "default value not supported with length(NAME) supplied" if defined $defaults{$var}; return; } die "length($var) not supported for $var type '$type' ($tk) because it doesn't contain \$length_var\n" if $expr !~ m/\$length_var\b/; } if ($expr =~ /DO_ARRAY_ELEM/) { blurt("Error: '$subtype' not in typemap"), return unless defined($type_kind{$subtype}); blurt("Error: No INPUT definition for type '$subtype', typekind '$type_kind{$subtype}' found"), return unless defined $input_expr{$type_kind{$subtype}} ; $subexpr = $input_expr{$type_kind{$subtype}}; $subexpr =~ s/\$type/\$subtype/g; $subexpr =~ s/ntype/subtype/g; $subexpr =~ s/\$arg/ST(ix_$var)/g; $subexpr =~ s/\n\t/\n\t\t/g; $subexpr =~ s/is not of (.*\")/[arg %d] is not of $1, ix_$var + 1/g; $subexpr =~ s/\$var/${var}[ix_$var - $argoff]/; $expr =~ s/DO_ARRAY_ELEM/$subexpr/; } if ($expr =~ m#/\*.*scope.*\*/#i) { # "scope" in C comments $ScopeThisXSUB = 1; } if (defined($defaults{$var})) { $expr =~ s/(\t+)/$1 /g; $expr =~ s/ /\t/g; if ($name_printed) { print ";\n"; } else { eval qq/print "\\t$var;\\n"/; warn $@ if $@; } if ($defaults{$var} eq 'NO_INIT') { $deferred{post_input} .= eval qq/"\\n\\tif (items >= $num) {\\n$expr;\\n\\t}\\n"/; } else { $deferred{post_input} .= eval qq/"\\n\\tif (items < $num)\\n\\t $var = $defaults{$var};\\n\\telse {\\n$expr;\\n\\t}\\n"/; } warn $@ if $@; } elsif ($ScopeThisXSUB or $expr !~ /^\s*\$var =/) { if ($name_printed) { print ";\n"; } else { eval qq/print "\\t$var;\\n"/; warn $@ if $@; } $deferred{post_input} .= eval qq/"\\n$expr;\\n"/; warn $@ if $@; } else { die "panic: do not know how to handle this branch for function pointers" if $name_printed; eval qq/print "$expr;\\n"/; warn $@ if $@; } if ($expr = $input_expr{$tk.":pre_call"}) { $deferred{pre_call} .= eval "qq\a$expr;\n\a"; warn $@ if $@; } } sub generate_output { local($type, $num, $var, $do_setmagic, $do_push) = @_; local($arg) = "ST(" . ($num - ($num != 0)) . ")"; local($argoff) = $num - 1; local($ntype); $type = TidyType($type) ; if ($type =~ /^array\(([^,]*),(.*)\)/) { print "\t$arg = sv_newmortal();\n"; print "\tsv_setpvn($arg, (char *)$var, $2 * sizeof($1));\n"; print "\tSvSETMAGIC($arg);\n" if $do_setmagic; } else { blurt("Error: '$type' not in typemap"), return unless defined($type_kind{$type}); blurt("Error: No OUTPUT definition for type '$type', typekind '$type_kind{$type}' found"), return unless defined $output_expr{$type_kind{$type}} ; ($ntype = $type) =~ s/\s*\*/Ptr/g; $ntype =~ s/\(\)//g; ($subtype = $ntype) =~ s/(?:Array)?(?:Ptr)?$//; if ($expr = $output_expr{$type_kind{$type}.":init"}) { eval "print qq\a$expr\a"; warn $@ if $@; } $expr = $output_expr{$type_kind{$type}}; if ($expr =~ /DO_ARRAY_ELEM/) { blurt("Error: '$subtype' not in typemap"), return unless defined($type_kind{$subtype}); blurt("Error: No OUTPUT definition for type '$subtype', typekind '$type_kind{$subtype}' found"), return unless defined $output_expr{$type_kind{$subtype}} ; $subexpr = $output_expr{$type_kind{$subtype}}; $subexpr =~ s/ntype/subtype/g; $subexpr =~ s/\$arg/ST(ix_$var)/g; $subexpr =~ s/\$var/${var}[ix_$var]/g; $subexpr =~ s/\n\t/\n\t\t/g; $expr =~ s/DO_ARRAY_ELEM\n/$subexpr/; eval "print qq\a$expr\a"; warn $@ if $@; print "\t\tSvSETMAGIC(ST(ix_$var));\n" if $do_setmagic; } elsif ($var eq 'RETVAL') { if ($expr =~ /^\t\$arg = new/) { # We expect that $arg has refcnt 1, so we need to # mortalize it. eval "print qq\a$expr\a"; warn $@ if $@; print "\tsv_2mortal(ST($num));\n"; print "\tSvSETMAGIC(ST($num));\n" if $do_setmagic; } elsif ($expr =~ /^\s*\$arg\s*=/) { # We expect that $arg has refcnt >=1, so we need # to mortalize it! eval "print qq\a$expr\a"; warn $@ if $@; print "\tsv_2mortal(ST(0));\n"; print "\tSvSETMAGIC(ST(0));\n" if $do_setmagic; } else { # Just hope that the entry would safely write it # over an already mortalized value. By # coincidence, something like $arg = &sv_undef # works too. print "\tST(0) = sv_newmortal();\n"; eval "print qq\a$expr\a"; warn $@ if $@; # new mortals don't have set magic } } elsif ($do_push) { print "\tPUSHs(sv_newmortal());\n"; $arg = "ST($num)"; eval "print qq\a$expr\a"; warn $@ if $@; print "\tSvSETMAGIC($arg);\n" if $do_setmagic; } elsif ($arg =~ /^ST\(\d+\)$/) { my $suffix; if (defined $defaults{$var}) { print "\tif (items >= $num) {\n"; $suffix = "\t}"; } eval "print qq\a$expr\a"; warn $@ if $@; print "\tSvSETMAGIC($arg);\n" if $do_setmagic; print "$suffix\n" if $suffix; } } } sub map_type { my($type, $varname) = @_; # C++ has :: in types too so skip this $type =~ tr/:/_/ unless $hiertype; $type =~ s/^array\(([^,]*),(.*)\).*/$1 */s; if ($varname) { if ($varname && $type =~ / \( \s* \* (?= \s* \) ) /xg) { (substr $type, pos $type, 0) = " $varname "; } else { $type .= "\t$varname"; } } $type; } ######################################################### package ExtUtils::ParseXS::CountLines; use strict; use vars qw($SECTION_END_MARKER); sub TIEHANDLE { my ($class, $cfile, $fh) = @_; $cfile =~ s/\\/\\\\/g; $SECTION_END_MARKER = qq{#line --- "$cfile"}; return bless {buffer => '', fh => $fh, line_no => 1, }, $class; } sub PRINT { my $self = shift; for (@_) { $self->{buffer} .= $_; while ($self->{buffer} =~ s/^([^\n]*\n)//) { my $line = $1; ++ $self->{line_no}; $line =~ s|^\#line\s+---(?=\s)|#line $self->{line_no}|; print {$self->{fh}} $line; } } } sub PRINTF { my $self = shift; my $fmt = shift; $self->PRINT(sprintf($fmt, @_)); } sub DESTROY { # Not necessary if we're careful to end with a "\n" my $self = shift; print {$self->{fh}} $self->{buffer}; } sub UNTIE { # This sub does nothing, but is neccessary for references to be released. } sub end_marker { return $SECTION_END_MARKER; } 1; __END__ =head1 NAME ExtUtils::ParseXS - converts Perl XS code into C code =head1 SYNOPSIS use ExtUtils::ParseXS qw(process_file); process_file( filename => 'foo.xs' ); process_file( filename => 'foo.xs', output => 'bar.c', 'C++' => 1, typemap => 'path/to/typemap', hiertype => 1, except => 1, prototypes => 1, versioncheck => 1, linenumbers => 1, optimize => 1, prototypes => 1, ); =head1 DESCRIPTION C will compile XS code into C code by embedding the constructs necessary to let C functions manipulate Perl values and creates the glue necessary to let Perl access those functions. The compiler uses typemaps to determine how to map C function parameters and variables to Perl values. The compiler will search for typemap files called I. It will use the following search path to find default typemaps, with the rightmost typemap taking precedence. ../../../typemap:../../typemap:../typemap:typemap =head1 EXPORT None by default. C may be exported upon request. =head1 FUNCTIONS =over 4 =item process_xs() This function processes an XS file and sends output to a C file. Named parameters control how the processing is done. The following parameters are accepted: =over 4 =item B Adds C to the C code. Default is false. =item B Retains C<::> in type names so that C++ hierachical types can be mapped. Default is false. =item B Adds exception handling stubs to the C code. Default is false. =item B Indicates that a user-supplied typemap should take precedence over the default typemaps. A single typemap may be specified as a string, or multiple typemaps can be specified in an array reference, with the last typemap having the highest precedence. =item B Generates prototype code for all xsubs. Default is false. =item B Makes sure at run time that the object file (derived from the C<.xs> file) and the C<.pm> files have the same version number. Default is true. =item B Adds C<#line> directives to the C output so error messages will look like they came from the original XS file. Default is true. =item B Enables certain optimizations. The only optimization that is currently affected is the use of Is by the output C code (see L). Not optimizing may significantly slow down the generated code, but this is the way B of 5.005 and earlier operated. Default is to optimize. =item B Enable recognition of C, C and C declarations. Default is true. =item B Enable recognition of ANSI-like descriptions of function signature. Default is true. =item B I have no clue what this does. Strips function prefixes? =back =item errors() This function returns the number of [a certain kind of] errors encountered during processing of the XS file. =back =head1 AUTHOR Based on xsubpp code, written by Larry Wall. Maintained by Ken Williams, =head1 COPYRIGHT Copyright 2002-2003 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Based on the ExtUtils::xsubpp code by Larry Wall and the Perl 5 Porters, which was released under the same license terms. =head1 SEE ALSO L, ExtUtils::xsubpp, ExtUtils::MakeMaker, L, L. =cut Memcached-libmemcached-1.001801/t/lib/ExtUtils/xsubpp0000644000175000017500000000763712522723506020722 0ustar seansean#!./miniperl require 5.002; use ExtUtils::ParseXS qw(process_file); use Getopt::Long; my %args = (); my $usage = "Usage: xsubpp [-v] [-csuffix csuffix] [-except] [-prototypes] [-noversioncheck] [-nolinenumbers] [-nooptimize] [-noinout] [-noargtypes] [-s pattern] [-typemap typemap]... file.xs\n"; Getopt::Long::Configure qw(no_auto_abbrev no_ignore_case); @ARGV = grep {$_ ne '-C++'} @ARGV; # Allow -C++ for backward compatibility GetOptions(\%args, qw(hiertype! prototypes! versioncheck! linenumbers! optimize! inout! argtypes! object_capi! except! v typemap=s@ output=s s=s csuffix=s )) or die $usage; if ($args{v}) { print "xsubpp version $ExtUtils::ParseXS::VERSION\n"; exit; } @ARGV == 1 or die $usage; $args{filename} = shift @ARGV; process_file(%args); exit( ExtUtils::ParseXS::errors() ? 1 : 0 ); __END__ =head1 NAME xsubpp - compiler to convert Perl XS code into C code =head1 SYNOPSIS B [B<-v>] [B<-except>] [B<-s pattern>] [B<-prototypes>] [B<-noversioncheck>] [B<-nolinenumbers>] [B<-nooptimize>] [B<-typemap typemap>] [B<-output filename>]... file.xs =head1 DESCRIPTION This compiler is typically run by the makefiles created by L. I will compile XS code into C code by embedding the constructs necessary to let C functions manipulate Perl values and creates the glue necessary to let Perl access those functions. The compiler uses typemaps to determine how to map C function parameters and variables to Perl values. The compiler will search for typemap files called I. It will use the following search path to find default typemaps, with the rightmost typemap taking precedence. ../../../typemap:../../typemap:../typemap:typemap It will also use a default typemap installed as C. =head1 OPTIONS Note that the C MakeMaker option may be used to add these options to any makefiles generated by MakeMaker. =over 5 =item B<-hiertype> Retains '::' in type names so that C++ hierachical types can be mapped. =item B<-except> Adds exception handling stubs to the C code. =item B<-typemap typemap> Indicates that a user-supplied typemap should take precedence over the default typemaps. This option may be used multiple times, with the last typemap having the highest precedence. =item B<-output filename> Specifies the name of the output file to generate. If no file is specified, output will be written to standard output. =item B<-v> Prints the I version number to standard output, then exits. =item B<-prototypes> By default I will not automatically generate prototype code for all xsubs. This flag will enable prototypes. =item B<-noversioncheck> Disables the run time test that determines if the object file (derived from the C<.xs> file) and the C<.pm> files have the same version number. =item B<-nolinenumbers> Prevents the inclusion of `#line' directives in the output. =item B<-nooptimize> Disables certain optimizations. The only optimization that is currently affected is the use of Is by the output C code (see L). This may significantly slow down the generated code, but this is the way B of 5.005 and earlier operated. =item B<-noinout> Disable recognition of C, C and C declarations. =item B<-noargtypes> Disable recognition of ANSI-like descriptions of function signature. =item B<-C++> Currently doesn't do anything at all. This flag has been a no-op for many versions of perl, at least as far back as perl5.003_07. It's allowed here for backwards compatibility. =back =head1 ENVIRONMENT No environment variables are used. =head1 AUTHOR Originally by Larry Wall. Turned into the C module by Ken Williams. =head1 MODIFICATION HISTORY See the file F. =head1 SEE ALSO perl(1), perlxs(1), perlxstut(1), ExtUtils::ParseXS =cut Memcached-libmemcached-1.001801/t/26-get-cb.t0000644000175000017500000000341712522723506016672 0ustar seansean # tests for functions documented in memcached_get.pod # (except for memcached_fetch_result) use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( memcached_set memcached_get memcached_mget memcached_mget_into_hashref ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); my $items = 2; plan tests => 15; my ($rv, $rc, $flags); my $t1= time(); my $flag_orig = 0xF000F00F; my %data = map { ("k$_.$t1" => "v$_.$t1") } (1..$items); my ($get_cb_expected_defsv, @get_cb_expected_args); my $get_cb_called = 0; my $get_cb = sub { ++$get_cb_called; print "get_cb(@_)\n"; is $_, $get_cb_expected_defsv, '$_ should be the value'; is_deeply \@_, \@get_cb_expected_args, '@_ should be $key and $flags'; return; }; $memc->set_callback_coderefs(undef, $get_cb); print "test read-only access to values from callback\n"; ok memcached_set($memc, $_, $data{$_}, 0, $flag_orig) for keys %data; for my $k (keys %data) { $get_cb_expected_defsv = $data{$k}; @get_cb_expected_args = ( $k, $flag_orig ); is memcached_get($memc, $k), $data{$k}; } is $get_cb_called, scalar keys %data; $get_cb_called = 0; $memc->set_callback_coderefs(undef, sub { ++$get_cb_called; return }); my %got; ok memcached_mget_into_hashref($memc, [ keys %data ], \%got); is_deeply \%got, \%data; print "test modification of values by callback\n"; $get_cb = sub { $_ = uc($_).lc($_); $_[1] = 0xE0E0E0E0; return; }; $memc->set_callback_coderefs(undef, $get_cb); for my $k (keys %data) { my $v = $data{$k}; is memcached_get($memc, $k, my $flags), uc($v).lc($v); is $flags, 0xE0E0E0E0; } Memcached-libmemcached-1.001801/t/20-set.t0000644000175000017500000000076212522723506016316 0ustar seansean # tests for functions documented in memcached_set.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_set ), # other functions used by the tests qw( memcached_server_add memcached_create memcached_free ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 1; ok memcached_set($memc, 'abc', "this is a test"); Memcached-libmemcached-1.001801/t/02-subclass.t0000644000175000017500000000075612522723506017345 0ustar seansean# tests for functions documented in memcached_create.pod use strict; use warnings; use Test::More tests => 6; BEGIN { use_ok( 'Memcached::libmemcached', # functions explicitly tested by this file qw( ), # other functions used by the tests qw( )); } my ($memc, $memc2); ok $memc = Memcached::libmemcached->new; is ref $memc, 'Memcached::libmemcached'; undef $memc; { package MyMemc; use base qw(Memcached::libmemcached); } ok $memc = MyMemc->new; is ref $memc, 'MyMemc'; ok 1; Memcached-libmemcached-1.001801/t/pod.t0000644000175000017500000000035012522723506016057 0ustar seansean#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Memcached-libmemcached-1.001801/t/11-set-get-by-key.t0000644000175000017500000000351612522723506020271 0ustar seansean # tests for basic memcached_set & memcached_get # documented in memcached_set.pod and memcached_get.pod # test for the other functions are performed elsewhere use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_set_by_key memcached_get_by_key ), # other functions used by the tests qw( memcached_errstr MEMCACHED_NOTFOUND ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 13; my ($rv, $rc, $flags, $tmp); my $t1= time(); my $m1= "master-key"; # can't have spaces my $k1= "$0-test-key-$t1"; # can't have spaces my $v1= "$0 test value $t1"; # get_by_key (presumably non-existant) key print "memcached_get the not yet stored value\n"; is scalar memcached_get_by_key($memc, $m1, $k1, $flags=0, $rc=0), undef, 'should not exist yet and so should return undef'; # test set with expiry and flags ok memcached_set_by_key($memc, $m1, $k1, $v1, 1, 0xDEADCAFE); is memcached_get_by_key($memc, $m1, $k1, $flags=0, $rc=0), $v1; ok $rc; if ($flags == 0xCAFE) { warn "You're limited to 16 bit flags\n"; $flags = 0xDEADCAFE; } is sprintf("0x%X",$flags), '0xDEADCAFE', 'flags should be unchanged'; sleep 1; ok not defined memcached_get_by_key($memc, $m1, $k1, $flags=0, $rc=0); ok !$rc; cmp_ok memcached_errstr($memc), '==', MEMCACHED_NOTFOUND(); # repeat for value with a null byte to check value_length works my $smiley = "\x{263A}"; ok memcached_set_by_key($memc, $m1, $k1, $tmp = $smiley); is length $tmp, length $smiley, 'utf8 arg length should not be altered'; is $tmp, $smiley, 'utf8 arg should not be altered'; $tmp = memcached_get_by_key($memc, $m1, $k1, $flags, $rc=0); ok $rc; { local $TODO = "support utf8"; # XXX is $tmp, $smiley; pass "no inbuilt utf8 support\n"; } Memcached-libmemcached-1.001801/t/50-quit.t0000644000175000017500000000055012522723506016503 0ustar seansean # tests for functions documented in memcached_quit.pod use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( ), # other functions used by the tests qw( ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); plan tests => 1; ok $memc; Memcached-libmemcached-1.001801/t/25-get.t0000644000175000017500000000600112522723506016277 0ustar seansean # tests for functions documented in memcached_get.pod # (except for memcached_fetch_result) use strict; use warnings; use Test::More; use Memcached::libmemcached # functions explicitly tested by this file qw( memcached_get memcached_mget memcached_fetch ), # other functions used by the tests qw( memcached_set ); use lib 't/lib'; use libmemcached_test; my $memc = libmemcached_test_create(); my $items = 5; plan tests => ($items * 3) + 3 + 2 * (1 + $items * 2 + 1) + $items + 6 + $items + 7 + 1; my ($rv, $rc, $flags, $tmp); my $t1= time(); my %data = map { ("k$_.$t1" => "v$_.$t1") } (1..$items-2); # add extra long and extra short items to help spot buffer issues $data{"kL.LLLLLLLLLLLLLLLLLL"} = "vLLLLLLLLLLLLLLLLLLLL"; $data{"kS.S"} = "vS"; ok memcached_set($memc, $_, $data{$_}) for keys %data; is memcached_get($memc, $_), $data{$_} for keys %data; is $memc->get($_), $data{$_} for keys %data; ok !memcached_mget($memc, undef); ok !memcached_mget($memc, 0); ok !memcached_mget($memc, 1); for my $keys_ref ( [ keys %data ], { % data }, ) { ok memcached_mget($memc, $keys_ref); my %got; my $key; while (defined( my $value = memcached_fetch($memc, $key, $flags, $rc) )) { ok $rc, 'rc should be true'; is $flags, 0, 'flags should be 0'; print "memcached_fetch($key) => $value\n"; $got{ $key } = $value; } is_deeply \%got, \%data; } print "mget_into_hashref\n"; # tweak data so it's different from previous tests %data = map { $_ . "a" } %data; #use Data::Dumper; warn Dumper(\%data); ok memcached_set($memc, $_, $data{$_}) for keys %data; ok $memc->mget_into_hashref([ ], {}), 'should return true, even if no keys'; { my %h = (); ok $memc->mget_into_hashref([ 'none_such_foo' ], \%h), 'should return true, even if no results'; is_deeply \%h, {}, 'results should be empty'; } my %extra = ( foo => 'bar' ); # reset got data, but not to empty so we check the hash isn't erased my %got = %extra; ok $memc->mget_into_hashref([ keys %data ], \%got), 'should return true'; is_deeply \%got, { %data, %extra }; # refetch with duplicate keys, mainly to trigger realloc of key buffers ok $memc->mget_into_hashref([ (keys %data) x 10 ], \%got), 'should return true'; is_deeply \%got, { %data, %extra }; print "get_multi\n"; # tweak data so it's different from previous tests %data = map { $_ . "b" } %data; ok memcached_set($memc, $_, $data{$_}) for keys %data; is_deeply $memc->get_multi(), {}, 'should return empty hash for no keys'; is_deeply $memc->get_multi('none_such_foo'), {}, 'should return empty hash if no results'; $tmp = $memc->get_multi(keys %data); ok $tmp; is ref $tmp, 'HASH'; is scalar keys %$tmp, scalar keys %data; is_deeply $tmp, \%data, 'results should match'; # refetch with duplicate keys, mainly to trigger realloc of key buffers is_deeply $memc->get_multi((keys %data) x 10), \%data, 'should return true'; Memcached-libmemcached-1.001801/libmemcached.xs0000644000175000017500000010050712522723506017623 0ustar seansean/* * vim: expandtab:sw=4 * */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include #define MEMCACHED_CALLBACK_MALLOC_FUNCTION 4 #define MEMCACHED_CALLBACK_REALLOC_FUNCTION 5 #define MEMCACHED_CALLBACK_FREE_FUNCTION 6 /* See also the typemap as most of the interesting glue is there */ /* mapping C types to perl classes - keep typemap file in sync */ typedef memcached_st* Memcached__libmemcached; typedef uint32_t lmc_data_flags_t; typedef char* lmc_key; typedef char* lmc_value; typedef time_t lmc_expiration; /* pointer chasing: * * $memc is a scalar (SV) containing a reference (RV) to a hash (HV) with magic (mg): * * RV -> HV -> mg -> lmc_state -> memcached_st (-> MEMCACHED_CALLBACK_USER_DATA points back to lmc_state) * */ /* get a memcached_st structure from a $memc */ #define LMC_STATE_FROM_SV(sv) \ (mg_find(SvRV(sv), '~')->mg_obj) #define LMC_PTR_FROM_SV(sv) \ ((lmc_state_st*)LMC_STATE_FROM_SV(sv))->ptr /* get our lmc_state structure from a memcached_st ptr */ #define LMC_STATE_FROM_PTR(ptr) \ ((lmc_state_st*)memcached_callback_get(ptr, MEMCACHED_CALLBACK_USER_DATA, NULL)) /* get trace level from memcached_st ptr */ #define LMC_TRACE_LEVEL_FROM_PTR(ptr) \ ((ptr) ? LMC_STATE_FROM_PTR(ptr)->trace_level : 0) /* check memcached_return value counts as success */ #define LMC_RETURN_OK(ret) \ (ret==MEMCACHED_SUCCESS || ret==MEMCACHED_STORED || ret==MEMCACHED_DELETED || ret==MEMCACHED_END || ret==MEMCACHED_BUFFERED) /* store memcached_return value in our lmc_state structure */ #define LMC_RECORD_RETURN_ERR(what, ptr, ret) \ STMT_START { \ lmc_state_st* lmc_state = LMC_STATE_FROM_PTR(ptr); \ if (lmc_state) { \ if (lmc_state->trace_level > 1 || (lmc_state->trace_level && !LMC_RETURN_OK(ret))) \ warn("\t<= %s return %d %s", what, ret, memcached_strerror(ptr, ret)); \ lmc_state->last_return = ret; \ lmc_state->last_errno = memcached_last_error_errno(ptr); /* if MEMCACHED_ERRNO */ \ } else { /* should never happen */ \ warn("LMC_RECORD_RETURN_ERR(%d %s): no lmc_state structure in memcached_st so error not recorded!", \ ret, memcached_strerror(ptr, ret)); \ } \ } STMT_END /* ====================================================================================== */ typedef struct lmc_state_st lmc_state_st; typedef struct lmc_cb_context_st lmc_cb_context_st; /* context information for callbacks */ struct lmc_cb_context_st { lmc_state_st *lmc_state; SV *dest_sv; HV *dest_hv; memcached_return *rc_ptr; lmc_data_flags_t *flags_ptr; UV result_count; SV *get_cb; SV *set_cb; /* current set of keys for mget */ char **key_strings; size_t *key_lengths; IV key_alloc_count; }; /* perl api state information associated with an individual memcached_st */ struct lmc_state_st { memcached_st *ptr; HV *hv; /* pointer back to HV (not refcntd) */ IV trace_level; int options; memcached_return last_return; int last_errno; /* handy default fetch context for fetching single items */ lmc_cb_context_st *cb_context; /* points to _cb_context by default */ lmc_cb_context_st _cb_context; }; static lmc_state_st * lmc_state_new(memcached_st *ptr, HV *memc_hv) { char *trace = getenv("PERL_LIBMEMCACHED_TRACE"); lmc_state_st *lmc_state; Newz(0, lmc_state, 1, struct lmc_state_st); lmc_state->ptr = ptr; lmc_state->hv = memc_hv; lmc_state->cb_context = &lmc_state->_cb_context; lmc_state->cb_context->lmc_state = lmc_state; lmc_state->cb_context->set_cb = newSV(0); lmc_state->cb_context->get_cb = newSV(0); if (trace) { lmc_state->trace_level = (IV)atoi(trace); } return lmc_state; } /* ====================================================================================== */ static void _prep_keys_buffer(lmc_cb_context_st *lmc_cb_context, int keys_needed) { IV trace_level = lmc_cb_context->lmc_state->trace_level; if (keys_needed <= lmc_cb_context->key_alloc_count) { if (trace_level >= 9) warn("reusing keys buffer"); return; } if (!lmc_cb_context->key_strings) { Newx(lmc_cb_context->key_strings, keys_needed, char *); Newx(lmc_cb_context->key_lengths, keys_needed, size_t); if (trace_level >= 3) warn("new keys buffer"); } else { keys_needed *= 1.2; Renew(lmc_cb_context->key_strings, keys_needed, char *); Renew(lmc_cb_context->key_lengths, keys_needed, size_t); if (trace_level >= 3) warn("growing keys buffer %d->%d", (int)lmc_cb_context->key_alloc_count, keys_needed); } lmc_cb_context->key_alloc_count = keys_needed; } static memcached_return _prep_keys_lengths(memcached_st *ptr, SV *keys_rv, char ***out_keys, size_t **out_key_length, unsigned int *out_number_of_keys) { SV *keys_sv; unsigned int number_of_keys; char **keys; size_t *key_length; int i = 0; lmc_state_st *lmc_state = LMC_STATE_FROM_PTR(ptr); lmc_cb_context_st *lmc_cb_context = lmc_state->cb_context; if (!SvROK(keys_rv)) return MEMCACHED_NO_KEY_PROVIDED; keys_sv = SvRV(keys_rv); if (SvRMAGICAL(keys_rv)) /* disallow tied arrays for now */ return MEMCACHED_NO_KEY_PROVIDED; if (SvTYPE(keys_sv) == SVt_PVAV) { number_of_keys = AvFILL(keys_sv)+1; if (number_of_keys > lmc_cb_context->key_alloc_count) _prep_keys_buffer(lmc_cb_context, number_of_keys); keys = lmc_cb_context->key_strings; key_length = lmc_cb_context->key_lengths; for (i = 0; i < number_of_keys; i++) { keys[i] = SvPV(AvARRAY(keys_sv)[i], key_length[i]); } } else if (SvTYPE(keys_sv) == SVt_PVHV) { HE *he; I32 retlen; hv_iterinit((HV*)keys_sv); number_of_keys = HvKEYS(keys_sv); if (number_of_keys > lmc_cb_context->key_alloc_count) _prep_keys_buffer(lmc_cb_context, number_of_keys); keys = lmc_cb_context->key_strings; key_length = lmc_cb_context->key_lengths; while ( (he = hv_iternext((HV*)keys_sv)) ) { keys[i] = hv_iterkey(he, &retlen); key_length[i++] = retlen; } } else { return MEMCACHED_NO_KEY_PROVIDED; } *out_number_of_keys = number_of_keys; *out_keys = keys; *out_key_length = key_length; return MEMCACHED_SUCCESS; } /* ====================================================================================== */ /* --- callbacks for memcached_fetch_execute --- */ static unsigned int _cb_prep_store_into_sv_of_hv(memcached_st *ptr, memcached_result_st *result, void *context) { /* Set dest_sv to the appropriate sv in dest_hv */ /* Called before _cb_store_into_sv when fetching into a hash */ lmc_cb_context_st *lmc_cb_context = context; SV **svp = hv_fetch( lmc_cb_context->dest_hv, memcached_result_key_value(result), memcached_result_key_length(result), 1); lmc_cb_context->dest_sv = *svp; return 0; } static unsigned int _cb_store_into_sv(memcached_st *ptr, memcached_result_st *result, void *context) { /* Store result value and flags into places specified by lmc_cb_context */ /* This is the 'core' fetch callback. Increments result_count. */ lmc_cb_context_st *lmc_cb_context = context; ++lmc_cb_context->result_count; *lmc_cb_context->flags_ptr = memcached_result_flags(result); sv_setpvn(lmc_cb_context->dest_sv, memcached_result_value(result), memcached_result_length(result)); if (lmc_cb_context->lmc_state->trace_level >= 2) warn("fetched %s (value len %d, flags %lu)\n", memcached_result_key_value(result), (int) memcached_result_length(result), (long unsigned int)memcached_result_flags(result)); return 0; } /* XXX - Notes: * Perl callbacks are called as * * sub { * my ($key, $flags) = @_; # with $_ containing the value * } * * Modifications to $_ (value) and $_[1] (flags) propagate to other callbacks, * and thus to libmemcached. * Callbacks can't recurse within the same $memc at the moment. */ static unsigned int _cb_fire_perl_cb(lmc_cb_context_st *lmc_cb_context, SV *callback_sv, SV *key_sv, SV *value_sv, SV *flags_sv, SV *cas_sv) { int items; dSP; ENTER; SAVETMPS; SAVE_DEFSV; /* local($_) = $value */ DEFSV = value_sv; PUSHMARK(SP); EXTEND(SP, 2); PUSHs(key_sv); PUSHs(flags_sv); if (cas_sv) PUSHs(cas_sv); PUTBACK; items = call_sv(callback_sv, G_ARRAY); SPAGAIN; if (items) /* may use returned items for signalling later */ croak("callback returned non-empty list"); FREETMPS; LEAVE; return 0; } static unsigned int _cb_fire_perl_set_cb(memcached_st *ptr, SV *key_sv, SV *value_sv, SV *flags_sv) { /* XXX note different api to _cb_fire_perl_get_cb */ lmc_state_st *lmc_state = LMC_STATE_FROM_PTR(ptr); lmc_cb_context_st *lmc_cb_context = lmc_state->cb_context; unsigned int status; if (!SvOK(lmc_cb_context->set_cb)) return 0; status = _cb_fire_perl_cb(lmc_cb_context, lmc_cb_context->set_cb, key_sv, value_sv, flags_sv, NULL); return status; } static unsigned int _cb_fire_perl_get_cb(memcached_st *ptr, memcached_result_st *result, void *context) { /* designed to be called via memcached_fetch_execute() */ lmc_cb_context_st *lmc_cb_context = context; SV *key_sv, *value_sv, *flags_sv, *cas_sv; unsigned int status; if (!SvOK(lmc_cb_context->get_cb)) return 0; /* these SVs may get cached inside lmc_cb_context_st and reused across calls */ /* which would save the create,mortalize,destroy costs for each invocation */ key_sv = sv_2mortal(newSVpv(memcached_result_key_value(result), memcached_result_key_length(result))); value_sv = lmc_cb_context->dest_sv; flags_sv = sv_2mortal(newSVuv(*lmc_cb_context->flags_ptr)); if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_SUPPORT_CAS)) { uint64_t cas = memcached_result_cas(result); warn("cas not fully supported"); /* if sizeof UV < sizeof uint64_t */ cas_sv = sv_2mortal(newSVuv(cas)); } else cas_sv = NULL; SvREADONLY_on(key_sv); /* just to be sure for now, may allow later */ status = _cb_fire_perl_cb(lmc_cb_context, lmc_cb_context->get_cb, key_sv, value_sv, flags_sv, cas_sv); /* recover potentially modified values */ *lmc_cb_context->flags_ptr = SvUV(flags_sv); return status; } typedef unsigned int (*memcached_callback_fp)(memcached_st *ptr, memcached_result_st *result, void *context); memcached_callback_fp lmc_store_hv_get[3][3] = { { _cb_prep_store_into_sv_of_hv, _cb_store_into_sv, }, { _cb_prep_store_into_sv_of_hv, _cb_store_into_sv, _cb_fire_perl_get_cb, }, }; memcached_callback_fp lmc_store_sv_get[3][3] = { { _cb_store_into_sv, }, { _cb_store_into_sv, _cb_fire_perl_get_cb, }, }; /* ====================================================================================== */ static SV * _fetch_one_sv(memcached_st *ptr, lmc_data_flags_t *flags_ptr, memcached_return *error_ptr) { lmc_cb_context_st *lmc_cb_context = LMC_STATE_FROM_PTR(ptr)->cb_context; int callback_ix = 0; memcached_callback_fp callbacks[5]; callbacks[callback_ix++] = _cb_store_into_sv; if (SvOK(lmc_cb_context->get_cb)) callbacks[callback_ix++] = _cb_fire_perl_get_cb; callbacks[callback_ix ] = NULL; if (*error_ptr != MEMCACHED_SUCCESS) /* did preceeding mget succeed */ return &PL_sv_undef; lmc_cb_context->dest_sv = newSV(0); lmc_cb_context->flags_ptr = flags_ptr; lmc_cb_context->rc_ptr = error_ptr; lmc_cb_context->result_count = 0; *error_ptr = memcached_fetch_execute(ptr, (memcached_execute_fn *)callbacks, lmc_cb_context, callback_ix); if (lmc_cb_context->result_count == 0 && (*error_ptr == MEMCACHED_SUCCESS || *error_ptr == MEMCACHED_END)) *error_ptr = MEMCACHED_NOTFOUND; /* to match memcached_get behaviour */ else if (lmc_cb_context->result_count > 0 && *error_ptr == MEMCACHED_END) *error_ptr = MEMCACHED_SUCCESS; /* to match memcached_get behaviour */ return lmc_cb_context->dest_sv; } static memcached_return _fetch_all_into_hashref(memcached_st *ptr, memcached_return rc, HV *dest_ref) { lmc_cb_context_st *lmc_cb_context = LMC_STATE_FROM_PTR(ptr)->cb_context; lmc_data_flags_t flags; int callback_ix = 0; memcached_callback_fp callbacks[5]; callbacks[callback_ix++] = _cb_prep_store_into_sv_of_hv; callbacks[callback_ix++] = _cb_store_into_sv; if (SvOK(lmc_cb_context->get_cb)) callbacks[callback_ix++] = _cb_fire_perl_get_cb; callbacks[callback_ix ] = NULL; lmc_cb_context->dest_hv = dest_ref; lmc_cb_context->flags_ptr = &flags; /* local, not safe for caller */ lmc_cb_context->rc_ptr = &rc; /* local, not safe for caller */ lmc_cb_context->result_count = 0; /* rc is the return code from the preceeding mget */ if (!LMC_RETURN_OK(rc)) { if (rc == MEMCACHED_INVALID_ARGUMENTS) { /* when number_of_keys==0 memcached_mget returns MEMCACHED_INVALID_ARGUMENTS * which we'd normally translate into a false return value * but that's not really appropriate here */ return MEMCACHED_SUCCESS; } return rc; } rc = memcached_fetch_execute(ptr, (memcached_execute_fn *)callbacks, (void *)lmc_cb_context, callback_ix); if (rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_SUCCESS) { return MEMCACHED_SUCCESS; /* This is a success, no matter what */ } return rc; } static memcached_return_t _walk_stats_cb(const memcached_instance_st *instance, const char *key, size_t key_length, const char *value, size_t value_length, void *cb) { dSP; int items; /* callback is called with key, value, hostname, typename */ PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpv(key, key_length))); XPUSHs(sv_2mortal(newSVpv(value, value_length))); XPUSHs(sv_2mortal(newSVpvf("%s:%d", memcached_server_name(instance), memcached_server_port(instance)))); XPUSHs(DEFSV); /* XXX deprecated $stats_arg in $_ */ PUTBACK; items = call_sv((SV*)cb, G_ARRAY); SPAGAIN; if (items) /* XXX may use returned items for signalling later */ croak("walk_stats callback returned non-empty list"); return MEMCACHED_SUCCESS; } MODULE=Memcached::libmemcached PACKAGE=Memcached::libmemcached PROTOTYPES: DISABLED INCLUDE: const-xs.inc =head2 Functions For Managing libmemcached Objects =cut Memcached__libmemcached memcached_create(Memcached__libmemcached ptr=NULL) ALIAS: new = 1 PREINIT: SV *class_sv = (items >= 1) ? ST(0) : NULL; INIT: ptr = NULL; /* force null even if arg provided */ PERL_UNUSED_VAR(ix); Memcached__libmemcached memcached_clone(Memcached__libmemcached clone, Memcached__libmemcached source) PREINIT: SV *class_sv = (items >= 1) ? ST(0) : NULL; INIT: clone = NULL; /* force null even if arg provided */ unsigned int memcached_server_count(Memcached__libmemcached ptr) memcached_return memcached_server_add(Memcached__libmemcached ptr, char *hostname, unsigned int port=0) memcached_return memcached_server_add_with_weight(Memcached__libmemcached ptr, char *hostname, unsigned int port=0, unsigned int weight) memcached_return memcached_server_add_unix_socket(Memcached__libmemcached ptr, char *socket) memcached_return memcached_server_add_unix_socket_with_weight(Memcached__libmemcached ptr, char *socket, unsigned int weight) void memcached_free(Memcached__libmemcached ptr) INIT: if (!ptr) /* garbage or already freed this sv */ XSRETURN_EMPTY; POSTCALL: LMC_STATE_FROM_PTR(ptr)->ptr = NULL; void DESTROY(SV *sv) PPCODE: lmc_state_st *lmc_state; lmc_cb_context_st *lmc_cb_context; lmc_state = (lmc_state_st*)LMC_STATE_FROM_SV(sv); if (lmc_state->trace_level >= 2) { warn("DESTROY sv %p, state %p, ptr %p", SvRV(sv), lmc_state, lmc_state->ptr); if (lmc_state->trace_level >= 9) sv_dump(sv); } if (lmc_state->ptr) memcached_free(lmc_state->ptr); lmc_cb_context = lmc_state->cb_context; sv_free(lmc_cb_context->get_cb); sv_free(lmc_cb_context->set_cb); Safefree(lmc_cb_context->key_strings); Safefree(lmc_cb_context->key_lengths); sv_unmagic(SvRV(sv), '~'); /* disconnect lmc_state from HV */ Safefree(lmc_state); UV memcached_behavior_get(Memcached__libmemcached ptr, memcached_behavior flag) memcached_return memcached_behavior_set(Memcached__libmemcached ptr, memcached_behavior flag, uint64_t data) memcached_return memcached_callback_set(Memcached__libmemcached ptr, memcached_callback flag, SV *data) CODE: /* we only allow setting of known-safe flags */ switch (flag) { case MEMCACHED_CALLBACK_PREFIX_KEY: RETVAL = memcached_callback_set(ptr, flag, SvPV_nolen(data)); break; default: RETVAL = MEMCACHED_FAILURE; break; } OUTPUT: RETVAL SV * memcached_callback_get(Memcached__libmemcached ptr, memcached_callback flag, IN_OUT memcached_return ret=NO_INIT) PREINIT: void *data = NULL; CODE: RETVAL = &PL_sv_undef; /* we only allow setting of known-safe flags */ switch (flag) { case MEMCACHED_CALLBACK_PREFIX_KEY: data = memcached_callback_get(ptr, flag, &ret); /* libmemcached treats empty prefix as an error */ /* we treat it more pragmatically */ RETVAL = newSVpv((data) ? data : "", 0); break; default: ret = MEMCACHED_FAILURE; break; } OUTPUT: RETVAL =head2 Functions for Setting Values in memcached =cut memcached_return memcached_set(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration= 0, lmc_data_flags_t flags= 0) memcached_return memcached_set_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration=0, lmc_data_flags_t flags=0) memcached_return memcached_add (Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration= 0, lmc_data_flags_t flags=0) memcached_return memcached_add_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration=0, lmc_data_flags_t flags=0) memcached_return memcached_append(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key),\ lmc_value value, size_t length(value),\ lmc_expiration expiration= 0, lmc_data_flags_t flags=0) memcached_return memcached_append_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration=0, lmc_data_flags_t flags=0) memcached_return memcached_prepend(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration= 0, lmc_data_flags_t flags=0) memcached_return memcached_prepend_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration=0, lmc_data_flags_t flags=0) memcached_return memcached_replace(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration= 0, lmc_data_flags_t flags=0) memcached_return memcached_replace_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration=0, lmc_data_flags_t flags=0) memcached_return memcached_cas(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration= 0, lmc_data_flags_t flags=0, uint64_t cas) memcached_return memcached_cas_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_value value, size_t length(value), \ lmc_expiration expiration= 0, lmc_data_flags_t flags=0, uint64_t cas) =head2 Functions for Incrementing and Decrementing Values from memcached =cut memcached_return memcached_increment(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ unsigned int offset, IN_OUT uint64_t value=NO_INIT) memcached_return memcached_decrement(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ unsigned int offset, IN_OUT uint64_t value=NO_INIT) memcached_return memcached_increment_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ unsigned int offset, IN_OUT uint64_t value=NO_INIT) memcached_return memcached_decrement_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ unsigned int offset, IN_OUT uint64_t value=NO_INIT) memcached_return memcached_increment_with_initial (Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ unsigned int offset, \ uint64_t initial, \ lmc_expiration expiration= 0, \ IN_OUT uint64_t value=NO_INIT) memcached_return memcached_decrement_with_initial (Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ unsigned int offset, \ uint64_t initial, \ lmc_expiration expiration= 0, \ IN_OUT uint64_t value=NO_INIT) memcached_return memcached_increment_with_initial_by_key (Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ unsigned int offset, \ uint64_t initial, \ lmc_expiration expiration= 0, \ IN_OUT uint64_t value=NO_INIT) memcached_return memcached_decrement_with_initial_by_key (Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ unsigned int offset, \ uint64_t initial, \ lmc_expiration expiration= 0, \ IN_OUT uint64_t value=NO_INIT) =head2 Functions for Fetching Values from memcached =cut SV * memcached_get(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ IN_OUT lmc_data_flags_t flags=0, \ IN_OUT memcached_return error=0) CODE: /* rc is the return code from the preceeding mget */ error = memcached_mget_by_key(ptr, NULL, 0, (const char * const*)&key, &XSauto_length_of_key, 1); RETVAL = _fetch_one_sv(ptr, &flags, &error); OUTPUT: RETVAL SV * memcached_get_by_key(Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ IN_OUT lmc_data_flags_t flags=0, \ IN_OUT memcached_return error=0) CODE: error = memcached_mget_by_key(ptr, master_key, XSauto_length_of_master_key, (const char * const*)&key, &XSauto_length_of_key, 1); RETVAL = _fetch_one_sv(ptr, &flags, &error); OUTPUT: RETVAL memcached_return memcached_mget(Memcached__libmemcached ptr, SV *keys_rv) PREINIT: char **keys; size_t *key_length; unsigned int number_of_keys; CODE: if ((RETVAL = _prep_keys_lengths(ptr, keys_rv, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { RETVAL = memcached_mget(ptr, (const char * const*)keys, key_length, number_of_keys); } OUTPUT: RETVAL memcached_return memcached_mget_by_key(Memcached__libmemcached ptr, lmc_key master_key, size_t length(master_key), SV *keys_rv) PREINIT: char **keys; size_t *key_length; unsigned int number_of_keys; CODE: if ((RETVAL = _prep_keys_lengths(ptr, keys_rv, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { RETVAL = memcached_mget_by_key(ptr, master_key, XSauto_length_of_master_key, (const char * const*)keys, key_length, number_of_keys); } OUTPUT: RETVAL lmc_value memcached_fetch(Memcached__libmemcached ptr, \ OUT lmc_key key, \ IN_OUT lmc_data_flags_t flags=0, \ IN_OUT memcached_return error=0) PREINIT: size_t key_length=0; size_t value_length=0; char key_buffer[MEMCACHED_MAX_KEY]; INIT: key = key_buffer; CODE: RETVAL = memcached_fetch(ptr, key, &key_length, &value_length, &flags, &error); OUTPUT: RETVAL =head2 Functions for Managing Results from memcached /* memcached_result_st * memcached_fetch_result(Memcached__libmemcached ptr,\ memcached_result_st *result,\ memcached_return *error) */ =cut =head2 Functions for Deleting Values from memcached =cut memcached_return memcached_delete(Memcached__libmemcached ptr, \ lmc_key key, size_t length(key), \ lmc_expiration expiration= 0) memcached_return memcached_delete_by_key (Memcached__libmemcached ptr, \ lmc_key master_key, size_t length(master_key), \ lmc_key key, size_t length(key), \ lmc_expiration expiration= 0) =head2 Functions for Accessing Statistics from memcached =cut =head2 Miscellaneous Functions =cut memcached_return memcached_verbosity(Memcached__libmemcached ptr, unsigned int verbosity) memcached_return memcached_flush(Memcached__libmemcached ptr, lmc_expiration expiration=0) void memcached_quit(Memcached__libmemcached ptr) const char * memcached_strerror(Memcached__libmemcached ptr, memcached_return rc) const char * memcached_lib_version() =head2 Memcached::libmemcached Methods =cut IV trace_level(Memcached__libmemcached ptr, IV level = IV_MIN) PREINIT: lmc_state_st* lmc_state; CODE: lmc_state = LMC_STATE_FROM_PTR(ptr); RETVAL = LMC_TRACE_LEVEL_FROM_PTR(ptr); /* return previous level */ if (level != IV_MIN && lmc_state) lmc_state->trace_level = level; OUTPUT: RETVAL SV * errstr(Memcached__libmemcached ptr) ALIAS: memcached_errstr = 1 PREINIT: lmc_state_st* lmc_state; CODE: if (!ptr) XSRETURN_UNDEF; PERL_UNUSED_VAR(ix); RETVAL = newSV(0); lmc_state = LMC_STATE_FROM_PTR(ptr); /* setup return value as a dualvar with int err code and string error message */ sv_setiv(RETVAL, lmc_state->last_return); sv_setpv(RETVAL, memcached_strerror(ptr, lmc_state->last_return)); if (lmc_state->last_return == MEMCACHED_ERRNO) { /* lmc_state->last_errno should be meaningful here but sometimes isn't */ /* See https://rt.cpan.org/Ticket/Display.html?id=41299 */ sv_catpvf(RETVAL, " %s", (lmc_state->last_errno) ? strerror(lmc_state->last_errno) : "(last_errno==0!)"); } SvIOK_on(RETVAL); /* set as dualvar */ OUTPUT: RETVAL SV * get(Memcached__libmemcached ptr, SV *key_sv) PREINIT: char *master_key = NULL; size_t master_key_len = 0; char *key; size_t key_len; memcached_return error; uint32_t flags; CODE: if (SvROK(key_sv) && SvTYPE(SvRV(key_sv)) == SVt_PVAV) { AV *av = (AV*)SvRV(key_sv); master_key = SvPV(AvARRAY(av)[0], master_key_len); key_sv = AvARRAY(av)[1]; warn("get with array ref as key is deprecated"); } key = SvPV(key_sv, key_len); error = memcached_mget_by_key(ptr, master_key, master_key_len, (const char * const*)&key, &key_len, 1); RETVAL = _fetch_one_sv(ptr, &flags, &error); OUTPUT: RETVAL void get_multi(Memcached__libmemcached ptr, ...) PREINIT: HV *hv = newHV(); SV *dest_ref = sv_2mortal(newRV_noinc((SV*)hv)); char **keys; size_t *key_length; unsigned int number_of_keys = --items; memcached_return ret; lmc_cb_context_st *lmc_cb_context; PPCODE: /* XXX does not support keys being [ $master_key, $key ] */ lmc_cb_context = LMC_STATE_FROM_PTR(ptr)->cb_context; if (number_of_keys > lmc_cb_context->key_alloc_count) _prep_keys_buffer(lmc_cb_context, number_of_keys); keys = lmc_cb_context->key_strings; key_length = lmc_cb_context->key_lengths; while (--items >= 0) { keys[items] = SvPV(ST(items+1), key_length[items]); } ret = memcached_mget(ptr, (const char * const*)keys, key_length, number_of_keys); _fetch_all_into_hashref(ptr, ret, hv); if (lmc_cb_context->lmc_state->trace_level) warn("get_multi of %d keys: mget %s, fetched %d", number_of_keys, memcached_strerror(ptr,ret), (int)lmc_cb_context->result_count); PUSHs(dest_ref); XSRETURN(1); memcached_return mget_into_hashref(Memcached__libmemcached ptr, SV *keys_ref, HV *dest_ref) ALIAS: memcached_mget_into_hashref = 1 PREINIT: char **keys; size_t *key_length; unsigned int number_of_keys; CODE: PERL_UNUSED_VAR(ix); if ((RETVAL = _prep_keys_lengths(ptr, keys_ref, &keys, &key_length, &number_of_keys)) == MEMCACHED_SUCCESS) { RETVAL = memcached_mget(ptr, (const char * const*)keys, key_length, number_of_keys); RETVAL = _fetch_all_into_hashref(ptr, RETVAL, dest_ref); } OUTPUT: RETVAL void set_callback_coderefs(Memcached__libmemcached ptr, SV *set_cb, SV *get_cb) ALIAS: memcached_set_callback_coderefs = 1 PREINIT: lmc_state_st *lmc_state; CODE: PERL_UNUSED_VAR(ix); if (SvOK(set_cb) && !(SvROK(set_cb) && SvTYPE(SvRV(set_cb)) == SVt_PVCV)) croak("set_cb is not a reference to a subroutine"); if (SvOK(get_cb) && !(SvROK(get_cb) && SvTYPE(SvRV(get_cb)) == SVt_PVCV)) croak("get_cb is not a reference to a subroutine"); lmc_state = LMC_STATE_FROM_PTR(ptr); sv_setsv(lmc_state->cb_context->set_cb, set_cb); sv_setsv(lmc_state->cb_context->get_cb, get_cb); memcached_return walk_stats(Memcached__libmemcached ptr, SV *stats_args, CV *cb) PREINIT: Memcached__libmemcached clone; CODE: if (LMC_TRACE_LEVEL_FROM_PTR(ptr) >= 2) warn("walk_stats(%s, %s)\n", SvPV_nolen(stats_args), SvPV_nolen((SV*)CvGV(cb))); clone = memcached_clone(NULL, ptr); memcached_behavior_set(clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 0); ENTER; SAVETMPS; /* this local($_) assignment is to aid migration from the old api */ SAVE_DEFSV; /* local($_) */ DEFSV = sv_mortalcopy(stats_args); RETVAL = memcached_stat_execute(clone, SvPV_nolen(stats_args), _walk_stats_cb, cb); if (!LMC_RETURN_OK(RETVAL)) { LMC_RECORD_RETURN_ERR("memcached_stat_execute", ptr, RETVAL); LMC_STATE_FROM_PTR(ptr)->last_errno = memcached_last_error_errno(clone); memcached_free(clone); XSRETURN_NO; } memcached_free(clone); FREETMPS; LEAVE; OUTPUT: RETVAL SV * get_server_for_key(Memcached__libmemcached ptr, char *key) CODE: memcached_return_t err; const memcached_instance_st *sp = memcached_server_by_key(ptr, key, strlen(key), &err); if (sp == NULL) XSRETURN_UNDEF; RETVAL = newSVpvf("%s:%d", memcached_server_name(sp), memcached_server_port(sp) ); /* memcached_instance_free(sp); ??? */ OUTPUT: RETVAL Memcached-libmemcached-1.001801/libmemcached.pm0000644000175000017500000006161712522723506017615 0ustar seanseanpackage Memcached::libmemcached; use warnings; use strict; =head1 NAME Memcached::libmemcached - Thin fast full interface to the libmemcached client API =head1 VERSION Version 1.001801 (with libmemcached-1.0.18 embedded) =cut our $VERSION = '1.001801'; # also alter in pod above use Carp; use base qw(Exporter); use Memcached::libmemcached::API; our @EXPORT_OK = ( libmemcached_functions(), libmemcached_constants(), ); our %EXPORT_TAGS = libmemcached_tags(); require XSLoader; XSLoader::load('Memcached::libmemcached', $VERSION); =head1 SYNOPSIS use Memcached::libmemcached; $memc = memcached_create(); memcached_server_add($memc, "localhost"); memcached_set($memc, $key, $value); $value = memcached_get($memc, $key); =head1 DESCRIPTION Memcached::libmemcached is a very thin, highly efficient, wrapper around the libmemcached library. It's implemented almost entirely in C. It gives full access to the rich functionality offered by libmemcached. libmemcached is fast, light on memory usage, thread safe, and provide full access to server side methods. - Synchronous and Asynchronous support. - TCP and Unix Socket protocols. - A half dozen or so different hash algorithms. - Implementations of the new cas, replace, and append operators. - Man pages written up on entire API. - Implements both modulo and consistent hashing solutions. (Memcached::libmemcached is fairly new and not all the functions in libmemcached have perl interfaces yet. It's usually trivial to add functions - just a few lines in libmemcached.xs, a few lines of documentation, and a few lines of testing. Volunteers welcome!) The libmemcached library documentation (which is bundled with this module) serves as the primary reference for the functionality. This documentation provides summary of the functions, along with any issues specific to this perl interface, and references to the documentation for the corresponding functions in the underlying library. For more information on libmemcached, see L =head1 CONVENTIONS =head2 Terminology The term "memcache" is used to refer to the C structure at the heart of the libmemcached library. We'll use $memc to represent this structure in perl code. (The libmemcached library documentation uses C.) =head2 Traditional and Object-Oriented There are two ways to use the functionality offered by this module: B<*> You can import the functions you want to use and call them explicitly. B<*> Or, you can use $memc as an object and call most of the functions as methods. You can do that for any function that takes a $memc (ptr) as its first argument, which is almost all of them. Since the primary focus of this module is to be a thin wrapper around libmemcached, the bulk of this documentation describes the traditional functional interface. The object-oriented interface is mainly targeted at modules wishing to subclass Memcached::libmemcached, such as Cache::Memcached::libmemcached. For more information see L. =head2 Function Names and Arguments The function names in the libmemcached library have exactly the same names in Memcached::libmemcached. The function arguments are also the same as the libmemcached library and documentation, with two exceptions: B<*> There are no I arguments. Wherever the libmemcached documentation shows a length argument (input or output) the corresponding argument doesn't exist in the Perl API because it's not needed. B<*> Some arguments are optional. Many libmemcached function arguments are I: the argument is the address of the value that the function will modify. For these the perl function will modify the argument directly if it can. For example, in this call: $value = memcached_get($memc, $key, $flags, $rc); The $flags and $rc arguments are output values that are modified by the memcached_get() function. See the L section for the fine detail of how each argument type is handled. =head2 Return Status Most of the functions return an integer status value. This is shown as C in the libmemcached documentation. In the perl interface this value is I returned directly. Instead a simple boolean is returned: true for 'success', defined but false for some 'unsuccessful' conditions like 'not found', and undef for all other cases (i.e., errors). All the functions documented below return this simple boolean value unless otherwise indicated. The actual C integer value, and corresponding error message, for the last libmemcached function call can be accessed via the L method. =head2 Unimplemented Functions Functions relating to managing lists of servers (memcached_server_push, and memcached_server_list) have not been implemented because they're not needed and likely to be deprecated by libmemcached. Functions relating to iterating through results (memcached_result_*) have not been implemented yet. They're not a priority because similar functionality is available via the callbacks. See L. =cut =head1 EXPORTS All the public functions in libmemcached are available for import. All the public constants and enums in libmemcached are also available for import. Exporter tags are defined for each enum. This allows you to import groups of constants easily. For example, to enable consistent hashing you could use: use Memcached::libmemcached qw(:memcached_behavior :memcached_server_distribution); memcached_behavior_set($memc, MEMCACHED_BEHAVIOR_DISTRIBUTION(), MEMCACHED_DISTRIBUTION_CONSISTENT()); The L module allows patterns in the import list, so to import all the functions, for example, you can use: use Memcached::libmemcached qw(/^memcached/); Refer to L for a full list of the available constants and the tags they are grouped by. To see a list of all available functions and constants you can execute: perl -MMemcached::libmemcached -le 'print $_ for @Memcached::libmemcached::EXPORT_OK' =head1 FUNCTIONS =head2 Functions For Managing Memcaches =head3 memcached_create my $memc = memcached_create(); Creates and returns a 'memcache' that represents the state of communication with a set of memcached servers. See L. =head3 memcached_clone my $memc = memcached_clone(undef, undef); XXX Not currently recommended for use. See L. =head3 memcached_free memcached_free($memc); Frees the memory associated with $memc. After calling it $memc can't be used. See L. =head3 memcached_server_count $server_count= memcached_server_count($memc); Returns a count of the number of servers associated with $memc. See L. =head3 memcached_server_add =head3 memcached_server_add_with_weight memcached_server_add($memc, $hostname, $port); memcached_server_add_with_weight($memc, $hostname, $port, $weight); Adds details of a single memcached server (accessed via TCP/IP) to $memc. See L. The default weight is 0. =head3 memcached_server_add_unix_socket =head3 memcached_server_add_unix_socket_with_weight memcached_server_add_unix_socket($memc, $socket_path); memcached_server_add_unix_socket_with_weight($memc, $socket_path); Adds details of a single memcached server (accessed via a UNIX domain socket) to $memc. See L. The default weight is 0. =head3 memcached_behavior_set memcached_behavior_set($memc, $option_key, $option_value); Changes the value of a particular option. See L. =head3 memcached_behavior_get memcached_behavior_get($memc, $option_key); Get the value of a particular option. See L. =head3 memcached_callback_set memcached_callback_set($memc, $flag, $value); Set callback flag value. The only flag currently supported is C. The $value must be less than MEMCACHED_PREFIX_KEY_MAX_SIZE (eg 128) bytes. It also can't be empty L =head3 memcached_callback_get $value = memcached_callback_set($memc, $flag, $return_status); Get callback flag value. Sets return status in $return_status. The only flag currently supported is C. Returns undef on error. =cut =head2 Functions for Setting Values See L. =head3 memcached_set memcached_set($memc, $key, $value); memcached_set($memc, $key, $value, $expiration, $flags); Set $value as the value of $key. $expiration and $flags are both optional and default to 0. =head3 memcached_add memcached_add($memc, $key, $value); memcached_add($memc, $key, $value, $expiration, $flags); Like L except that an error is returned if $key I already stored in the server. =head3 memcached_replace memcached_replace($memc, $key, $value); memcached_replace($memc, $key, $value, $expiration, $flags); Like L except that an error is returned if $key I already error is returned. =head3 memcached_prepend memcached_prepend($memc, $key, $value); memcached_prepend($memc, $key, $value, $expiration, $flags); Prepend $value to the value of $key. $key must already exist. $expiration and $flags are both optional and default to 0. =head3 memcached_append memcached_append($memc, $key, $value); memcached_append($memc, $key, $value, $expiration, $flags); Append $value to the value of $key. $key must already exist. $expiration and $flags are both optional and default to 0. =head3 memcached_cas memcached_cas($memc, $key, $value, $expiration, $flags, $cas) Overwrites data in the server stored as $key as long as $cas still has the same value in the server. Cas is still buggy in memached. Turning on support for it in libmemcached is optional. Please see memcached_behavior_set() for information on how to do this. XXX and the memcached_result_cas() function isn't implemented yet so you can't get the $cas to use. =cut =head2 Functions for Fetching Values See L. The memcached_fetch_result() and =head3 memcached_get $value = memcached_get($memc, $key); $value = memcached_get($memc, $key, $flags, $rc); Get and return the value of $key. Returns undef on error. Also updates $flags to the value of the flags stored with $value, and updates $rc with the return code. =head3 memcached_mget memcached_mget($memc, \@keys); memcached_mget($memc, \%keys); Triggers the asynchronous fetching of multiple keys at once. For multiple key operations it is always faster to use this function. You I then use memcached_fetch() or memcached_fetch_result() to retrieve any keys found. No error is given on keys that are not found. Instead of this function, you'd normally use the L method. =head3 memcached_fetch $value = memcached_fetch($memc, $key); $value = memcached_fetch($memc, $key, $flag, $rc); Fetch the next $key and $value pair returned in response to a memcached_mget() call. Returns undef if there are no more values. If $flag is given then it will be updated to whatever flags were stored with the value. If $rc is given then it will be updated to the return code. This is similar to L except its fetching the results from the previous call to L and $key is an output parameter instead of an input. Usually you'd just use the L method instead. =cut =head2 Functions for Incrementing and Decrementing Values memcached servers have the ability to increment and decrement unsigned integer keys (overflow and underflow are not detected). This gives you the ability to use memcached to generate shared sequences of values. See L. =head3 memcached_increment memcached_increment( $key, $offset, $new_value_out ); Increments the integer value associated with $key by $offset and returns the new value in $new_value_out. =head3 memcached_decrement memcached_decrement( $key, $offset, $new_value_out ); Decrements the integer value associated with $key by $offset and returns the new value in $new_value_out. =head3 memcached_increment_with_initial memcached_increment_with_initial( $key, $offset, $initial, $expiration, $new_value_out ); Increments the integer value associated with $key by $offset and returns the new value in $new_value_out. If the object specified by key does not exist, one of two things may happen: If the expiration value is MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero. =head3 memcached_decrement_with_initial memcached_decrement_with_initial( $key, $offset, $initial, $expiration, $new_value_out ); Decrements the integer value associated with $key by $offset and returns the new value in $new_value_out. If the object specified by key does not exist, one of two things may happen: If the expiration value is MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero. =head3 memcached_increment_by_key =head3 memcached_decrement_by_key =head3 memcached_increment_with_initial_by_key =head3 memcached_decrement_with_initial_by_key These are the master key equivalents of the above. They all take an extra initial $master_key parameter. =head2 Functions for Deleting Values from memcached See L. =head3 memcached_delete memcached_delete($memc, $key); memcached_delete($memc, $key, $expiration); Delete $key. If $expiration is greater than zero then the key is deleted by memcached after that many seconds. =cut =head2 Functions for Accessing Statistics from memcached Not yet implemented. See L. See L. =cut =head2 Miscellaneous Functions =head2 memcached_lib_version $version = memcached_lib_version() Returns a simple version string, like "1.0.17", representing the libmemcached version (version of the client library, not server). =head2 memcached_version $version = memcached_version($memc) ($version1, $version2, $version3) = memcached_version($memc) Returns the I version of all the memcached servers. In scalar context returns a simple version string, like "1.2.3". In list context returns the individual version component numbers. Returns an empty list if there was an error. Note that the return value differs from that of the underlying libmemcached library memcached_version() function. =cut sub memcached_version { my $self = shift; my @versions; # XXX should be rewritten to use underlying memcached_version then # return the lowest cached version from the server structures $self->walk_stats('', sub { my ($key, $value, $hostport) = @_; push @versions, [ split /\./, $value ] if $key eq 'version'; return; }); my $lowest = (sort { $a->[0] <=> $b->[0] or $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @versions)[0]; return join '.', @$lowest unless wantarray; return @$lowest; } =head2 memcached_verbosity memcached_verbosity($memc, $verbosity) Modifies the "verbosity" of the memcached servers associated with $memc. See L. =head3 memcached_flush memcached_flush($memc, $expiration); Wipe clean the contents of associated memcached servers. See L. =head2 memcached_quit memcached_quit($memc) Disconnect from all currently connected servers and reset libmemcached state associated with $memc. Not normally called explicitly. See L. =head3 memcached_strerror $string = memcached_strerror($memc, $return_code) memcached_strerror() takes a C value and returns a string describing the error. The string should be treated as read-only (it may be so in future versions). See also L. This function is rarely needed in the Perl interface because the return code is a I that already contains the error string. =cut =head2 Grouping Keys On Servers Normally libmemcached hashes the $key value to select which memcached server to communicate with. If you have several keys relating to a single object then it's very likely that the corresponding values will be stored in different memcached servers. It would be more efficient, in general, when setting and getting multiple related values, if it was possible to specify a different value to be hashed to select which memcached server to communicate with. With libmemcached, you can. Most of the functions for setting and getting values have C<*_by_key> variants for exactly this reason. These all have an extra $master_key parameter immediately after the $memc parameter. For example: memcached_mget($memc, \%keys, \%dest); memcached_mget_by_key($memc, $maskey_key, \%keys, \%dest); The C<*_by_key> variants all work in exactly the same way as the corresponding plain function, except that libmemcached hashes $master_key instead of $key to which memcached server to communicate with. If $master_key is undef then the functions behave the same as their non-by-key variants, i.e., $key is used for hashing. By-key variants of L: =head3 memcached_get_by_key =head3 memcached_mget_by_key By-key variants of L: =head3 memcached_set_by_key =head3 memcached_replace_by_key =head3 memcached_add_by_key =head3 memcached_append_by_key =head3 memcached_cas_by_key =head3 memcached_prepend_by_key =head3 memcached_delete_by_key =head1 OBJECT-ORIENTED INTERFACE =head2 Methods =head3 new $memc = $class->new; # same as memcached_create() =head3 errstr $errstr = $memc->errstr; Returns the error message and code from the most recent call to any libmemcached function that returns a C, which most do. The return value is a I, like $!, which means it has separate numeric and string values. The numeric value is the memcached_return integer value, and the string value is the corresponding error message what memcached_strerror() would return. As a special case, if the memcached_return is MEMCACHED_ERRNO, indicating a system call error, then the string returned by strerror() is appended. This method is also currently callable as memcached_errstr() for compatibility with an earlier version, but that deprecated alias will start warning and then cease to exist in future versions. =head3 mget_into_hashref $memc->mget_into_hashref( \@keys, \%dest_hash); # keys from array $memc->mget_into_hashref( \%keys, \%dest_hash); # keys from hash Combines memcached_mget() and a memcached_fetch() loop into a single highly efficient call. Fetched values are stored in \%dest_hash, updating existing values or adding new ones as appropriate. This method is also currently callable as memcached_mget_into_hashref() for compatibility with an earlier version, but that deprecated alias will start warning and then cease to exist in future versions. =head3 get_multi $hash_ref = $memc->get_multi( @keys ); Effectively the same as: $memc->mget_into_hashref( \@keys, $hash_ref = { } ) So it's very similar to L but less efficient for large numbers of keys (because the keys have to be pushed onto the argument stack) and less flexible (because you can't add/update elements into an existing hash). This method is provided to optimize subclasses that want to provide a Cache::Memcached compatible API with maximum efficiency. Note, however, that C does I support the L feature where a key can be a reference to an array [ $master_key, $key ]. Use L directly if you need that feature. =head3 get $value = $memc->get( $key ); Effectively the same as: $value = memcached_get( $memc, $key ); The C method also supports the L feature where $key can be a reference to an array [ $master_key, $key ]. In which case the call is effectively the same as: $value = memcached_get_by_key( $memc, $key->[0], $key->[1] ) =head3 set_callback_coderefs $memc->set_callback_coderefs(\&set_callback, \&get_callback); This interface is I and I. (It's also currently used by Cache::Memcached::libmemcached, so don't use it if you're using that module.) Specify functions which will be executed when values are set and/or get using $memc. When the callbacks are executed $_ is the value and the arguments are the key and flags value. Both $_ and the flags may be modified. Currently the functions must return an empty list. This method is also currently callable as memcached_set_callback_coderefs() for compatibility with an earlier version, but that deprecated alias will start warning and then cease to exist in future versions. =head3 walk_stats $memc->walk_stats( $stats_args, \&my_stats_callback ); This interface is I and I. Calls the memcached_stat_execute() function to issue a "STAT $stats_args" command to the connected memcached servers. The $stats_args argument is usually an empty string. The callback function is called for each return value from each server. The callback will be passed at least these parameters: sub my_stats_callback { my ($key, $value, $hostport) = @_; # Do what you like with the above! return; } Currently the callback I return an empty list. Prior to version 0.4402 the callback was passed a fourth argument which was a copy of the $stats_args value. That is no longer the case. As a I aid to migration, the C method does C and passes C<$_> as the forth argument. That will work so long as the code in the callback doesn't alter C<$_>. If your callback code requires $stats_args you should change it to be a closure instead. =head2 trace_level $memc->trace_level($trace_level); $trace_level = $memc->trace_level; Sets the trace level (see L). Returns the previous trace level. =head3 get_server_for_key $memc->get_server_for_key( $key ) This method uses I to get information about which server should contain the specified $key. It returns a string containing the hostname:port of the appropriate server, or undef on failure. =head1 EXTRA INFORMATION =head2 Tracing Execution $memc->trace_level($trace_level); If set >= 1 then any non-success memcached_return value will be logged via warn(). If set >= 2 or more then some data types will list conversions of input and output values for function calls. The C environment variable provides a default. The value is read when L is called. =head2 Type Mapping For pointer arguments, undef is mapped to null on input and null is mapped to undef on output. XXX expand with details from typemap file =head2 Deprecated Functions The following functions are available but deprecated in this release. In the next release they'll generate warnings. In a future release they'll be removed. =head3 memcached_errstr Use L instead. =head3 memcached_mget_into_hashref Use L instead. =head3 memcached_set_callback_coderefs Use L instead. =head1 AUTHOR EMERITUS Tim Bunce, C<< >> with help from Patrick Galbraith and Daisuke Maki. L =head1 CURRENT MAINTAINER Matthew Horsfall (alh) C<< >> Daisuke Maki C<< >> with occasional bursts of input from Tim Bunce. =head1 ACKNOWLEDGEMENTS Larry Wall for Perl, Brad Fitzpatrick for memcached, Brian Aker for libmemcached, and Patrick Galbraith and Daisuke Maki for helping with the implementation. =head1 PORTABILITY See Slaven Rezic's excellent CPAN Testers Matrix at L Along with Dave Cantrell's excellent CPAN Dependency tracker at L =head1 BUGS Please report any bugs or feature requests to the GitHub issue tracker at L. We will be notified, and then you'll automatically be notified of progress on your bug as we make changes. =head1 CONTRIBUTING The source is hosted at github: L Patches and volunteers always welcome. =head1 COPYRIGHT & LICENSE Copyright 2008 Tim Bunce, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Memcached::libmemcached Memcached-libmemcached-1.001801/responses.txt0000644000175000017500000000065612522723506017440 0ustar seanseanget MATCH_END - swallow_eol(state,0,1) MATCH_VALUE - break default = MEMCACHED_UNKNOWN set MATCH_STORED 1 MATCH_NOT_STORED 0 MATCH_NOT_FOUND 0 MATCH_EXISTS 0 default MEMCACHED_UNKOWN delete MATCH_DELETED 1 MATCH_NOT_FOUND 0 default MEMCACHED_UNKOWN arith MATCH_NOT_FOUND MEMCACHED_FAILURE MATCH_0 through MATCH_9: break ok MATCH_OK 1 default MEMCACHED_UNKNOWN version MATCH_VERSION break default MEMCACHED_UNKNOWN Memcached-libmemcached-1.001801/typemap0000644000175000017500000001406312522723506016255 0ustar seansean############################################################################### ## ## Typemap for Memcached::libmemcached objects ## ## Copyright (c) 2007 Tim Bunce ## All rights reserved. ## ############################################################################### ## vi:et:sw=4 ts=4 TYPEMAP # --- some basic types not in the perl 5.6 typemap const char * T_PV size_t T_UV # --- simple types --- memcached_behavior T_IV memcached_callback T_IV memcached_return T_RETURN # --- generic simple types --- # general uint16_t uint16_t T_UV # XXX need to at least document this as an issue # Could also check at build time if this perl has 64bit ints and use UV if so uint64_t T_NV # --- perl api private abstraction typedefs --- lmc_key T_KEY lmc_value T_VALUE lmc_expiration T_EXPIRATION lmc_data_flags_t T_FLAGS # --- complex types (incl. objects, typedef name encodes class name) --- # XXX memory management may be reworked to store structure in scalars Memcached__libmemcached T_MEMCACHED INPUT T_HVREF if (!SvROK($arg) || !SvTYPE(SvRV($arg))==SVt_PVHV) Perl_croak(aTHX_ \"$var is not a hash reference\"); $var = (HV*)SvRV($arg); INPUT T_RETURN /* T_RETURN */ $var = (SvOK($arg)) ? ($type)SvIV($arg) : 0; OUTPUT T_RETURN:init /* T_RETURN:init */ LMC_RECORD_RETURN_ERR(\"${func_name}\", ptr, $var); T_RETURN /* T_RETURN */ if (!SvREADONLY($arg)) { if (LMC_RETURN_OK($var)) { sv_setsv($arg, &PL_sv_yes); } else if ($var == MEMCACHED_NOTFOUND) { sv_setsv($arg, &PL_sv_no); } else { SvOK_off($arg); } } INPUT T_PV /* treat undef as null pointer (output does the inverse) */ $var = (SvOK($arg)) ? ($type)SvPV_nolen($arg) : NULL; INPUT T_KEY /* T_KEY */ $var = ($type)SvPV($arg, $length_var); OUTPUT T_KEY /* T_KEY */ /* assumes the existance of a key_length variable holding the length */ if (!SvREADONLY($arg)) sv_setpvn((SV*)$arg, $var, key_length); INPUT T_VALUE /* T_VALUE - main code in T_VALUE:pre_call below (so it can access/modify flags) */ /* mention $length_var here to keep ParseXS happy for now */ T_VALUE:pre_call /* T_VALUE:pre_call */ if (SvOK(LMC_STATE_FROM_PTR(ptr)->cb_context->set_cb)) { /* XXX ignoring flags till we have a better mechanism */ SV *key_sv, *value_sv, *flags_sv; /* these SVs may get cached inside lmc_cb_context_st and reused across calls */ /* which would save the create,mortalize,destroy costs for each invocation */ key_sv = sv_2mortal(newSVpv(key, STRLEN_length_of_key)); value_sv = sv_mortalcopy($arg); /* original SV, as it may be a ref */ flags_sv = sv_2mortal(newSVuv(flags)); SvREADONLY_on(key_sv); /* just to be sure for now, may allow later */ _cb_fire_perl_set_cb(ptr, key_sv, value_sv, flags_sv); /* recover possibly modified values (except key) */ $var = SvPV(value_sv, $length_var); flags = SvUV(flags_sv); } else { $var = ($type)SvPV($arg, $length_var); } OUTPUT T_VALUE /* T_VALUE */ /* assumes the existance of a value_length variable holding the length */ if (!SvREADONLY($arg)) sv_setpvn((SV*)$arg, $var, value_length); INPUT T_FLAGS /* T_FLAGS */ $var = (SvOK($arg)) ? ($type)SvUV($arg) : 0; OUTPUT T_FLAGS /* T_FLAGS */ if (!SvREADONLY($arg)) sv_setuv($arg, (UV)$var); INPUT T_EXPIRATION /* T_EXPIRATION */ $var = (SvOK($arg)) ? ($type)SvUV($arg) : 0; OUTPUT T_MEMCACHED /* T_MEMCACHED */ if (!$var) /* if null */ SvOK_off($arg); /* then return as undef instead of reaf to undef */ else { /* setup $arg as a ref to a blessed hash hv */ lmc_state_st *lmc_state; HV *hv = newHV(); const char *classname = \"${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\"; /* take (sub)class name to use from class_sv if appropriate */ if (class_sv && SvOK(class_sv) && sv_derived_from(class_sv, classname)) classname = (SvROK(class_sv)) ? sv_reftype(class_sv, 0) : SvPV_nolen(class_sv); sv_setsv($arg, sv_2mortal(newRV_noinc((SV*)hv))); (void)sv_bless($arg, gv_stashpv(classname, TRUE)); /* allocate an lmc_state struct and attach via MEMCACHED_CALLBACK_USER_DATA */ lmc_state = lmc_state_new($var, hv); memcached_callback_set($var, MEMCACHED_CALLBACK_USER_DATA, lmc_state); /* now attach $var to the HV */ /* done as two steps to avoid sv_magic SvREFCNT_inc and MGf_REFCOUNTED */ sv_magic((SV*)hv, NULL, '~', NULL, 0); LMC_STATE_FROM_SV($arg) = (void*)lmc_state; } if (LMC_TRACE_LEVEL_FROM_PTR($var) >= 2) warn(\"\t<= %s(%s %s = %p)\", \"${func_name}\", \"${ntype}\", \"${var}\", (void*)$var); INPUT T_MEMCACHED /* T_MEMCACHED */ if (!SvOK($arg)) { /* undef */ $var = NULL; /* treat as null */ } else if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\")) { if (SvROK($arg)) { $var = (memcached_st*)LMC_PTR_FROM_SV($arg); } else { /* memcached_st ptr already freed or is a class name */ $var = NULL; } } else croak(\"$var is not of type ${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\"); if (LMC_TRACE_LEVEL_FROM_PTR($var) >= 2) warn(\"\t=> %s(%s %s = 0x%p)\", \"${func_name}\", \"${ntype}\", \"${var}\", (void*)$var); Memcached-libmemcached-1.001801/ppport.h0000644000175000017500000046040212522723506016352 0ustar seansean#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- perl-libmemcached-trunk/ppport.h -- Perl/Pollution/Portability Version 3.13 Automatically created by Devel::PPPort running under perl 5.008006. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc perl-libmemcached-trunk/ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME perl-libmemcached-trunk/ppport.h - Perl/Pollution/Portability version 3.13 =head1 SYNOPSIS perl perl-libmemcached-trunk/ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from perl-libmemcached-trunk/ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.10.0. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl perl-libmemcached-trunk/ppport.h --list-provided to see which API elements are provided by perl-libmemcached-trunk/ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "perl-libmemcached-trunk/ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl perl-libmemcached-trunk/ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl perl-libmemcached-trunk/ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl perl-libmemcached-trunk/ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl perl-libmemcached-trunk/ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl perl-libmemcached-trunk/ppport.h --copy=.new To display portability information for the C function, use: perl perl-libmemcached-trunk/ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl perl-libmemcached-trunk/ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl perl-libmemcached-trunk/ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2007, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.13; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| CLASS|||n CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSV||| Gv_AMupdate||| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeVAL||5.004000| HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LVRET||| MARK||| MULTICALL||5.009005| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERL_ABS|5.008001||p PERL_BCDVERSION|5.009005||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.009005||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.009005||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_compiling|5.004050||p PL_copline|5.009005||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_expect|5.009005||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_last_in_gv|||n PL_laststatval|5.005000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofs_sv|||n PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rsfp_filters|5.004050||p PL_rsfp|5.004050||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p POP_MULTICALL||5.009005| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.009005| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg|5.007002||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.009005||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _pMY_CXT|5.007003||p aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.009005||p aTHXR|5.009005||p aTHX_|5.006000||p aTHX|5.006000||p add_data|||n addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_i_ncmp||| amagic_ncmp||| any_dup||| ao||| append_elem||| append_list||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fake||| av_fetch||| av_fill||| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| boot_core_xsutils||| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_anoncode||| ck_bitop||| ck_concat||| ck_defined||| ck_delete||| ck_die||| ck_eof||| ck_eval||| ck_exec||| ck_exists||| ck_exit||| ck_ftst||| ck_fun||| ck_glob||| ck_grep||| ck_index||| ck_join||| ck_lengthconst||| ck_lfun||| ck_listiob||| ck_match||| ck_method||| ck_null||| ck_open||| ck_readline||| ck_repeat||| ck_require||| ck_retarget||| ck_return||| ck_rfun||| ck_rvconst||| ck_sassign||| ck_select||| ck_shift||| ck_sort||| ck_spair||| ck_split||| ck_subr||| ck_substr||| ck_svconst||| ck_trunc||| ck_unpack||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init_zero|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| closest_cop||| convert||| cop_free||| cr_textfilter||| create_eval_scope||| croak_nocontext|||vn croak|||v csighandler||5.009003|n curmad||| custom_op_desc||5.007003| custom_op_name||5.007003| cv_ckproto_len||| cv_ckproto||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_undef||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.009005||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000| deprecate_old||| deprecate||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_where||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_chop||| do_close||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_kv||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pipe||| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch_body||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptosub||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs||5.006000| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| emulate_eaccess||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| fd_on_nosuid_fs||| feature_is_enabled||| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_script||| find_uninit_var||| first_symbol|||n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_arena||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags||5.009005| get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_2pv||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags||5.009002| gv_fetchpv||| gv_fetchsv||5.009002| gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs||5.009003| gv_stashpv||| gv_stashsv||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||5.009005| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_copy_hints_hv||| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_exists_ent||5.004000| hv_exists||| hv_fetch_common||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic_uvar_xkey||| hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incl_perldb||| incline||| incpush_if_exists||| incpush||| ingroup||| init_argv_symbols||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr||| intro_my||| intuit_method||| intuit_more||| invert||| io_close||| isALNUM||| isALPHA||| isDIGIT||| isLOWER||| isSPACE||| isUPPER||| is_an_int||| is_gv_magical_sv||| is_gv_magical||| is_handle_constructor|||n is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnumc_lc||5.006000| is_uni_alnumc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_alnumc||5.006000| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000| is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003| is_utf8_string_loc||5.008001| is_utf8_string||5.006001| is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword||| leave_scope||| lex_end||| lex_start||| linklist||| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhint||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_freeregexp||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall||| magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setbm||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_setfm||| magic_setglob||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| magicname||| make_matcher||| make_trie_failtable||| make_trie||| malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQ|5.004000||p memNE|5.004000||p mem_collxfrm||| mess_alloc||| mess_nocontext|||vn mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_find||| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_get_linear_isa_c3||5.009005| mro_get_linear_isa_dfs||5.009005| mro_get_linear_isa||5.009005| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mul128||| mulexp10|||n my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat||| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf||5.009003|vn my_stat||| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n my||| need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type||5.009005| newSVhek||5.009003| newSViv||| newSVnv||| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_share|5.007001||p newSVpvn|5.004050||p newSVpvs_share||5.009003| newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.009003| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr||| no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n offer_nice_chunk||| oopsAV||| oopsCV||| oopsHV||| op_clear||| op_const_sv||| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_null||5.007002| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_xmldump||| open_script||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package||| packlist||5.008001| pad_add_anon||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||5.009005| pad_swipe||| pad_tidy||| pad_undef||| parse_body||| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmflag||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| pregcomp||5.009005| pregexec||| pregfree||| prepend_elem||| prepend_madprops||| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display||5.006000| pv_escape||5.009004| pv_pretty||5.009004| pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch||| refcounted_he_free||| refcounted_he_new||| refcounted_he_value||| refkids||| refto||| ref||5.009003| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_stringify||5.009005| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly|||n regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy||| report_evil_fh||| report_uninit||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hek_flags|||n save_helem||5.004050| save_hints||5.005000| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||| save_padsv||5.007001| save_pptr||| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpv||5.007003| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| scope||| screaminstr||5.005000| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_csh||| set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| setdefout||| setenv_getix||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.009005| stdize_locale||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2nv||| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_mg|5.004050||p sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_does||5.009004| sv_dump||| sv_dup||| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc||| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.009005|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003||p sv_pvn||| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swap_match_buff||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_intern_clear||| sys_intern_dup||| sys_intern_init||| taint_env||| taint_proper||| tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vdie_common||| vdie_croak_common||| vdie||| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| write_no_mem||| write_to_stderr||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs||| xmldump_sub||| xmldump_vindent||| yyerror||| yylex||| yyparse||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $define; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2; } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (\$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error perl-libmemcached-trunk/ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif # define NUM2PTR(any,d) (any)(PTRV)(d) # define PTR2IV(p) INT2PTR(IV,p) # define PTR2UV(p) INT2PTR(UV,p) # define PTR2NV(p) NUM2PTR(NV,p) # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif /* !INT2PTR */ #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by perl-libmemcached-trunk/ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_laststatval laststatval # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting /* Replace: 0 */ #endif /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters * Do not use this variable. It is internal to the perl parser * and may change or even be removed in the future. Note that * as of perl 5.9.5 you cannot assign to this variable anymore. */ /* TODO: cannot assign to these vars; is it worth fixing? */ #if (PERL_BCDVERSION >= 0x5009005) # define PL_expect (PL_parser ? PL_parser->expect : 0) # define PL_copline (PL_parser ? PL_parser->copline : 0) # define PL_rsfp (PL_parser ? PL_parser->rsfp : (PerlIO *) 0) # define PL_rsfp_filters (PL_parser ? PL_parser->rsfp_filters : (AV *) 0) #endif #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn_mg(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv_mg(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv_mg(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv_mg(PUSHmortal, (UV)(u)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif /* Replace: 0 */ /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, perl-libmemcached-trunk/ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV * sv, STRLEN * lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV * sv, STRLEN * lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, 0, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, 0, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval >= (int)len) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File perl-libmemcached-trunk/ppport.h */ Memcached-libmemcached-1.001801/TODO0000644000175000017500000000303112522723506015334 0ustar seansean*** General: Stabilize stats api Document all typedef actions on input and output Resolve mapping of error codes to booleans (see parse_*_reply in http://search.cpan.org/src/KROKI/Cache-Memcached-Fast-0.07/src/client.c) ** Structure: Add PrintError & RaiseError flags *** CAS Add cas support - if sizeof(uint64_t) <= sizeof(UV) then use UV else use a newSV(sizeof(uint64_t)) and store the uint64_t as a binary string. *** 64bit issues Resolve other uint64_t issues, esp increment/decrement *** More flexible callbacks, something like: [ [ $bit_mask, \&callback, $callback_style ], [ $bit_mask, \&callback, $callback_style ], ... ] the code would iterate along the list and call each callback where any bits in $bit_mask are set in $flag. If $bit_mask is undef then the callback would be called unconditionally. $callback_style indicates how the key, value, flags etc. should be passed in and returned from the callback. Several different callback styles would be supported that correspond to the APIs used by Storable and IO::Zip, for example, so those could be plumbed in and called directly without needing any perl code (for the get, for the set the callbacks need extra logic to decide if the serialization and compression should be applied to the particular value). *** Random thoughts... For *_by_key functions, if $master_key is undef then use some per-$memc mechanism, such as a pre-stored scalar, or a callback, to get the value. Memcached-libmemcached-1.001801/META.json0000664000175000017500000000163612527462751016307 0ustar seansean{ "abstract" : "Thin fast full interface to the libmemcached client API", "author" : [ "Tim Bunce " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Memcached-libmemcached", "no_index" : { "directory" : [ "t", "inc" ] }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/timbunce/Memcached-libmemcached/issues/" }, "repository" : { "type" : "git", "url" : "git://github.com/timbunce/Memcached-libmemcached.git", "web" : "https://github.com/timbunce/Memcached-libmemcached" } }, "version" : "1.001801" } Memcached-libmemcached-1.001801/lib/0000755000175000017500000000000012527462751015424 5ustar seanseanMemcached-libmemcached-1.001801/lib/Memcached/0000755000175000017500000000000012527462751017272 5ustar seanseanMemcached-libmemcached-1.001801/lib/Memcached/libmemcached/0000755000175000017500000000000012527462751021667 5ustar seanseanMemcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_version.pm0000644000175000017500000000255412522723506025677 0ustar seanseanpackage Memcached::libmemcached::memcached_version; =head1 NAME memcached_lib_version, memcached_version - Get library version =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include const char * memcached_lib_version (void) memcached_return_t memcached_version (memcached_st *ptr) =head1 DESCRIPTION memcached_lib_version() is used to return a simple version string representing the libmemcached version (version of the client library, not server) memcached_version() is used to set the major, minor, and micro versions of each memcached server being used by the memcached_st connection structure. It returns the memcached server return code. =head1 RETURN A string with the version of libmemcached driver is returned from memcached_lib_version() A value of type C is returned from memcached_version() On success that value will be C. If called with the C behavior set, the value C will be returned. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_user_data.pm0000644000175000017500000000211412522723506026151 0ustar seanseanpackage Memcached::libmemcached::memcached_user_data; =head1 NAME memcached_set_user_data, memcached_get_user_data - Manage user specific data =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include void *memcached_get_user_data (memcached_st *ptr); void *memcached_set_user_data (memcached_st *ptr, void *data); =head1 DESCRIPTION libmemcached(3) allows you to store a pointer to a user specific data inside the memcached_st structure. memcached_set_user_data() is used to set the user specific data in the memcached_st structure. memcached_get_user_data() is used to retrieve the user specific data in the memcached_st structure. =head1 RETURN memcached_set_user_data() returns the previous value of the user specific data. memcached_get_user_data() returns the current value uf the user specific data. =head1 HOME To find out more information please check: L =head1 AUTHOR Trond Norbye, Etrond.norbye@gmail.comE =head1 SEE ALSO memcached(1) libmemcached(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_flush_buffers.pm0000644000175000017500000000175112522723506027045 0ustar seanseanpackage Memcached::libmemcached::memcached_flush_buffers; =head1 NAME memcached_flush_buffers - Flush buffers and send buffered commands =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_flush_buffers (memcached_st *ptr); =head1 DESCRIPTION memcached_flush_buffers() is used in conjunction with MEMCACHED_BEHAVIOR_BUFFER_REQUESTS (see memcached_behavior(3)) to flush all buffers by sending the buffered commands to the server for processing. =head1 RETURN A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Trond Norbye, Etrond.norbye@gmail.comE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) memcached_behavior(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_result_st.pm0000644000175000017500000000736112522723506026237 0ustar seanseanpackage Memcached::libmemcached::memcached_result_st; =head1 NAME memcached_result_create, memcached_result_free, memcached_result_key_value, memcached_result_key_length, memcached_result_value, memcached_result_length, memcached_result_flags, memcached_result_cas - Work with memcached_result_st =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_result_st * memcached_result_create (memcached_st *ptr, memcached_result_st *result); void memcached_result_free (memcached_result_st *result); const char * memcached_result_key_value (memcached_result_st *result); size_t memcached_result_key_length (const memcached_result_st *result); const char *memcached_result_value (memcached_result_st *ptr); size_t memcached_result_length (const memcached_result_st *ptr); uint32_t memcached_result_flags (const memcached_result_st *result) uint64_t memcached_result_cas (const memcached_result_st *result); memcached_return_t memcached_result_set_value (memcached_result_st *ptr, const char *value, size_t length) void memcached_result_set_flags (memcached_result_st *ptr, uint32_t flags) void memcached_result_set_expiration (memcached_result_st *ptr, time_t) =head1 DESCRIPTION libmemcached(3) can optionally return a memcached_result_st which acts as a result object. The result objects have added benefits over the character pointer returns in that they are forward compatible with new return items that future memcached servers may implement (the best current example of this is the CAS return item). The structures can also be reused which will save on calls to malloc(3). It is suggested that you use result objects over char * return functions. The structure of memcached_result_st has been encapsulated, you should not write code to directly access members of the structure. memcached_result_create() will either allocate memory for a memcached_result_st or will initialize a structure passed to it. memcached_result_free() will deallocate any memory attached to the structure. If the structure was also alloacted, it will deallocate it. memcached_result_key_value() returns the key value associated with the current result object. memcached_result_key_length() returns the key length associated with the current result object. memcached_result_value() returns the result value associated with the current result object. memcached_result_length() returns the result length associated with the current result object. memcached_result_flags() returns the flags associated with the current result object. memcached_result_cas() returns the cas associated with the current result object. This value will only be available if the server supports it. memcached_result_set_value() takes a byte array and a size and sets the result to this value. This function is used for trigger responses. void memcached_result_set_flags() takes a result structure and stores a new value for the flags field. void memcached_result_set_expiration(A) takes a result structure and stores a new value for the expiration field (this is only used by read through triggers). You may wish to avoid using memcached_result_create(3) with a stack based allocation. The most common issues related to ABI safety involve heap allocated structures. =head1 RETURN Varies, see particular functions. All structures must have memcached_result_free() called on them for cleanup purposes. Failure to do this will result in leaked memory. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_callback.pm0000644000175000017500000001014112522723506025735 0ustar seanseanpackage Memcached::libmemcached::memcached_callback; =head1 NAME memcached_callback_get, memcached_callback_set - Get and set a callback =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_callback_set (memcached_st *ptr, memcached_callback_t flag, void *data); void * memcached_callback_get (memcached_st *ptr, memcached_callback_t flag, memcached_return_t *error); =head1 DESCRIPTION libmemcached(3) can have callbacks set key execution points. These either provide function calls at points in the code, or return pointers to structures for particular usages. memcached_callback_get() takes a callback flag and returns the structure or function set by memcached_callback_set(). memcached_callback_set() changes the function/structure assigned by a callback flag. No connections are reset. You can use MEMCACHED_CALLBACK_USER_DATA to provide custom context if required for any of the callbacks =over 4 =item MEMCACHED_CALLBACK_CLEANUP_FUNCTION When memcached_delete() is called this function will be excuted. At the point of its execution all connections have been closed. =item MEMCACHED_CALLBACK_CLONE_FUNCTION When memcached_delete() is called this function will be excuted. At the point of its execution all connections have been closed. =item MEMCACHED_CALLBACK_PREFIX_KEY You can set a value which will be used to create a domain for your keys. The value specified here will be prefixed to each of your keys. The value can not be greater then MEMCACHED_PREFIX_KEY_MAX_SIZE - 1 and will reduce MEMCACHED_MAX_KEY by the value of your key. The prefix key is only applied to the primary key, not the master key. MEMCACHED_FAILURE will be returned if no key is set. In the case of a key which is too long MEMCACHED_BAD_KEY_PROVIDED will be returned. =item MEMCACHED_CALLBACK_USER_DATA This allows you to store a pointer to a specifc piece of data. This can be retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st will copy the pointer to the clone. =item MEMCACHED_CALLBACK_MALLOC_FUNCTION DEPRECATED: use memcached_set_memory_allocators instead. =item MEMCACHED_CALLBACK_REALLOC_FUNCTION DEPRECATED: use memcached_set_memory_allocators instead. =item MEMCACHED_CALLBACK_FREE_FUNCTION DEPRECATED: use memcached_set_memory_allocators instead. =item MEMCACHED_CALLBACK_GET_FAILURE This function implements the read through cache behavior. On failure of retrieval this callback will be called. You are responsible for populating the result object provided. This result object will then be stored in the server and returned to the calling process. You must clone the memcached_st in order to make use of it. The value will be stored only if you return MEMCACHED_SUCCESS or MEMCACHED_BUFFERED. Returning MEMCACHED_BUFFERED will cause the object to be buffered and not sent immediatly (if this is the default behavior based on your connection setup this will happen automatically). The prototype for this is: memcached_return_t (*memcached_trigger_key)(memcached_st *ptr, char *key, size_t key_length, memcached_result_st *result); =item MEMCACHED_CALLBACK_DELETE_TRIGGER This function implements a trigger upon successful deletion of a key. The memcached_st structure will need to be cloned in order to make use of it. The prototype for this is: typedef memcached_return_t (*memcached_trigger_delete_key)(memcached_st *ptr, char *key, size_t key_length); =back =head1 RETURN memcached_callback_get() return the function or structure that was provided. Upon error, nothing is set, null is returned, and the memcached_return_t argument is set to MEMCACHED_FAILURE. memcached_callback_set() returns MEMCACHED_SUCCESS upon successful setting, otherwise MEMCACHED_FAILURE on error. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_memory_allocators.pm0000644000175000017500000000630112522723506027737 0ustar seanseanpackage Memcached::libmemcached::memcached_memory_allocators; =head1 NAME memcached_set_memory_allocators, memcached_get_memory_allocators, memcached_set_memory_allocators_context - Manage memory allocator functions =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_set_memory_allocators (memcached_st *ptr, memcached_malloc_fn mem_malloc, memcached_free_fn mem_free, memcached_realloc_fn mem_realloc, memcached_calloc_fn mem_calloc, void *context); void memcached_get_memory_allocators (memcached_st *ptr, memcached_malloc_fn *mem_malloc, memcached_free_fn *mem_free, memcached_realloc_fn *mem_realloc, memcached_calloc_fn *mem_calloc); void * memcached_get_memory_allocators_context(const memcached_st *ptr); void * (*memcached_malloc_fn) (memcached_st *ptr, const size_t size, void *context); void * (*memcached_realloc_fn) (memcached_st *ptr, void *mem, const size_t size, void *context); void (*memcached_free_fn) (memcached_st *ptr, void *mem, void *context); void * (*memcached_calloc_fn) (memcached_st *ptr, size_t nelem, const size_t elsize, void *context); =head1 DESCRIPTION libmemcached(3) allows you to specify your own memory allocators optimized for your application. memcached_set_memory_allocators() is used to set the memory allocators used by the memcached instance specified by ptr. Please note that you cannot override only one of the memory allocators, you have to specify a complete new set if you want to override one of them. All of the memory allocation functions should behave as specified in the C99 standard. Specify NULL as all functions to reset them to the default values. memcached_get_memory_allocators() is used to get the currently used memory allocators by a mamcached handle. memcached_get_memory_allocators_context() returns the void * that was passed in during the call to memcached_set_memory_allocators(). The first argument to the memory allocator functions is a pointer to a memcached structure, the is passed as const and you will need to clone it in order to make use of any operation which would modify it. =head1 NOTES In version 0.38 all functions were modified to have a context void pointer passed to them. This was so that customer allocators could have their own space for memory. =head1 RETURN memcached_set_memory_allocators() return MEMCACHED_SUCCESS upon success, and MEMCACHED_FAILURE if you don't pass a complete set of function pointers. =head1 HOME To find out more information please check: L =head1 AUTHOR Trond Norbye, Etrond.norbye@gmail.comE Brian Aker, Ebrian@tangent.orf =head1 SEE ALSO memcached(1) libmemcached(3) memcached_get_user_data(3) memcached_set_user_data(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_verbosity.pm0000644000175000017500000000162412522723506026235 0ustar seanseanpackage Memcached::libmemcached::memcached_verbosity; =head1 NAME memcached_verbosity - Modifiy verbosity of servers =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_verbosity (memcached_st *ptr, unsigned int verbosity); =head1 DESCRIPTION memcached_verbosity() modifies the "verbosity" of the memcached(1) servers referenced in the C parameter. =head1 RETURN A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_get.pm0000644000175000017500000001727512522723506024777 0ustar seanseanpackage Memcached::libmemcached::memcached_get; =head1 NAME memcached_get, memcached_mget, memcached_fetch, memcached_mget_execute, memcached_mget_execute_by_key - Get a value =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_result_st * memcached_fetch_result (memcached_st *ptr, memcached_result_st *result, memcached_return_t *error); char * memcached_get (memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error); memcached_return_t memcached_mget (memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys); char * memcached_get_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error); memcached_return_t memcached_mget_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys); char * memcached_fetch (memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, memcached_return_t *error); memcached_return_t memcached_fetch_execute (memcached_st *ptr, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks); memcached_return_t memcached_mget_execute (memcached_st *ptr, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks); memcached_return_t memcached_mget_execute_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char * const *keys, const size_t *key_length, size_t number_of_keys, memcached_execute_fn *callback, void *context, uint32_t number_of_callbacks); =head1 DESCRIPTION memcached_get() is used to fetch an individual value from the server. You must pass in a key and its length to fetch the object. You must supply three pointer variables which will give you the state of the returned object. A uint32_t pointer to contain whatever flags you stored with the value, a size_t pointer which will be filled with size of of the object, and a memcached_return_t pointer to hold any error. The object will be returned upon success and NULL will be returned on failure. Any object returned by memcached_get() must be released by the caller application. memcached_mget() is used to select multiple keys at once. For multiple key operations it is always faster to use this function. This function always works asynchronously. memcached_fetch() is then used to retrieve any keys found. No error is given on keys that are not found. You must call either memcached_fetch() or memcached_fetch_result() after a successful call to memcached_mget(). You should continue to call these functions until they return NULL (aka no more values). If you need to quit in the middle of a memcached_get() call, execute a memcached_quit(). After you do this, you can issue new queries against the server. memcached_fetch() is used to fetch an individual value from the server. memcached_mget() must always be called before using this method. You must pass in a key and its length to fetch the object. You must supply three pointer variables which will give you the state of the returned object. A uint32_t pointer to contain whatever flags you stored with the value, a size_t pointer which will be filled with size of of the object, and a memcached_return_t pointer to hold any error. The object will be returned upon success and NULL will be returned on failure. MEMCACHD_END is returned by the *error value when all objects that have been found are returned. The final value upon MEMCACHED_END is null. Values returned by memcached_fetch() musted be free'ed by the caller. memcached_fetch() will be DEPRECATED in the near future, memcached_fetch_result() should be used instead. memcached_fetch_result() is used to return a memcached_result_st(3) structure from a memcached server. The result object is forward compatible with changes to the server. For more information please refer to the memcached_result_st(3) help. This function will dynamically allocate a result structure for you if you do not pass one to the function. memcached_fetch_execute() is a callback function for result sets. Instead of returning the results to you for processing, it passes each of the result sets to the list of functions you provide. It passes to the function a memcached_st that can be cloned for use in the called function (it can not be used directly). It also passes a result set which does not need to be freed. Finally it passes a "context". This is just a pointer to a memory reference you supply the calling function. Currently only one value is being passed to each function call. In the future there will be an option to allow this to be an array. memcached_mget_execute() and memcached_mget_execute_by_key() is similar to memcached_mget(), but it may trigger the supplied callbacks with result sets while sending out the queries. If you try to perform a really large multiget with memcached_mget() you may encounter a deadlock in the OS kernel (we fail to write data to the socket because the input buffer is full). memcached_mget_execute() solves this problem by processing some of the results before continuing sending out requests. Please note that this function is only available in the binary protocol. memcached_get_by_key() and memcached_mget_by_key() behave in a similar nature as memcached_get() and memcached_mget(). The difference is that they take a master key that is used for determining which server an object was stored if key partitioning was used for storage. All of the above functions are not supported when the C has been set. Executing any of these functions with this behavior on will result in C being returned or, for those functions which do not return a C, the error function parameter will be set to C. =head1 RETURN All objects returned must be freed by the calling application. memcached_get() and memcached_fetch() will return NULL on error. You must look at the value of error to determine what the actual error was. MEMCACHED_KEY_TOO_BIG is set to error whenever memcached_fetch() was used and the key was set larger then MEMCACHED_MAX_KEY, which was the largest key allowed for the original memcached ascii server. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_pool.pm0000644000175000017500000000667712522723506025175 0ustar seanseanpackage Memcached::libmemcached::memcached_pool; =head1 NAME memcached_pool_create, memcached_pool_destroy, memcached_pool_push, memcached_pool_pop - Manage pools =head1 LIBRARY C Client Library for memcached (libmemcachedutil, -lmemcachedutil) =head1 SYNOPSIS #include memcached_pool_st * memcached_pool_create(memcached_st* mmc, int initial, int max); memcached_st * memcached_pool_destroy(memcached_pool_st* pool); memcached_st * memcached_pool_pop (memcached_pool_st* pool, bool block, memcached_return_t *rc); memcached_return_t memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc); memcached_st *memcached_create (memcached_st *ptr); memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t data) memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t *value) =head1 DESCRIPTION memcached_pool_create() is used to create a connection pool of objects you may use to remove the overhead of using memcached_clone for short lived C objects. The mmc argument should be an initialised C structure, and a successfull invocation of memcached_pool_create takes full ownership of the variable (until it is released by memcached_pool_destroy). The C argument specifies the initial size of the connection pool, and the C argument specifies the maximum size the connection pool should grow to. Please note that the library will allocate a fixed size buffer scaled to the max size of the connection pool, so you should not pass MAXINT or some other large number here. memcached_pool_destroy() is used to destroy the connection pool created with memcached_pool_create() and release all allocated resources. It will return the pointer to the C structure passed as an argument to memcached_pool_create(), and returns the ownership of the pointer to the caller. memcached_pool_pop() is used to grab a connection structure from the connection pool. The block argument specifies if the function should block and wait for a connection structure to be available if we try to exceed the maximum size. memcached_pool_push() is used to return a connection structure back to the pool. memcached_pool_behavior_set() and memcached_pool_behagior_get() is used to get/set behavior flags on all connections in the pool. =head1 RETURN memcached_pool_create() returns a pointer to the newly created memcached_pool_st structure. On an allocation failure, it returns NULL. memcached_pool_destroy() returns the pointer (and ownership) to the memcached_st structure used to create the pool. If connections are in use it returns NULL. memcached_pool_pop() returns a pointer to a memcached_st structure from the pool (or NULL if an allocation cannot be satisfied). memcached_pool_push() returns MEMCACHED_SUCCESS upon success. memcached_pool_behavior_get() and memcached_pool_behavior_get() returns MEMCACHED_SUCCESS upon success. =head1 HOME To find out more information please check: L =head1 AUTHOR Trond Norbye, Etrond.norbye@gmail.comE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_create(3) memcached_free(3) libmemcachedutil(3) memcached_behavior_get(3) memcached_behavior_set(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_behavior.pm0000644000175000017500000002634212522723506026012 0ustar seanseanpackage Memcached::libmemcached::memcached_behavior; =head1 NAME memcached_behavior_get, memcached_behavior_set - Manipulate behavior =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include uint64_t memcached_behavior_get (memcached_st *ptr, memcached_behavior flag); memcached_return_t memcached_behavior_set (memcached_st *ptr, memcached_behavior flag, uint64_t data); =head1 DESCRIPTION libmemcached(3) behavior can be modified by use memcached_behavior_set(). Default behavior is the library strives to be quick and accurate. Some behavior, while being faster, can also result in not entirely accurate behavior (for instance, memcached_set() will always respond with C). memcached_behavior_get() takes a behavior flag and returns whether or not that behavior is currently enabled in the client. memcached_behavior_set() changes the value of a particular option of the client. It takes both a flag (listed below) and a value. For simple on or off options you just need to pass in a value of 1. Calls to memcached_behavior_set() will flush and reset all connections. =over 4 =item MEMCACHED_BEHAVIOR_USE_UDP Causes libmemcached(3) to use the UDP transport when communicating with a memcached server. Not all I/O operations are supported when this behavior is enababled. The following operations will return C when executed with the MEMCACHED_BEHAVIOR_USE_UDP enabled: memcached_version(), memcached_stat(), memcached_get(), memcached_get_by_key(), memcached_mget(), memcached_mget_by_key(), memcached_fetch(), memcached_fetch_result(), memcached_value_fetch(). All other operations are supported but are executed in a 'fire-and-forget' mode, in which once the client has executed the operation, no attempt will be made to ensure the operation has been received and acted on by the server. libmemcached(3) does not allow TCP and UDP servers to be shared within the same libmemached(3) client 'instance'. An attempt to add a TCP server when this behavior is enabled will result in a C, as will attempting to add a UDP server when this behavior has not been enabled. =item MEMCACHED_BEHAVIOR_NO_BLOCK Causes libmemcached(3) to use asychronous IO. This is the fastest transport available for storage functions. =item MEMCACHED_BEHAVIOR_SND_TIMEOUT This sets the microsecond behavior of the socket against the SO_SNDTIMEO flag. In cases where you cannot use non-blocking IO this will allow you to still have timeouts on the sending of data. =item MEMCACHED_BEHAVIOR_RCV_TIMEOUT This sets the microsecond behavior of the socket against the SO_RCVTIMEO flag. In cases where you cannot use non-blocking IO this will allow you to still have timeouts on the reading of data. =item MEMCACHED_BEHAVIOR_TCP_NODELAY Turns on the no-delay feature for connecting sockets (may be faster in some environments). =item MEMCACHED_BEHAVIOR_HASH Makes the default hashing algorithm for keys use MD5. The value can be set to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, MEMCACHED_HASH_FNV1A_32, MEMCACHED_HASH_JENKINS, MEMCACHED_HASH_HSIEH, and MEMCACHED_HASH_MURMUR. Each hash has it's advantages and it's weaknesses. If you don't know or don't care, just go with the default. Support for MEMCACHED_HASH_HSIEH is a compile time option that is disabled by default. To enable support for this hashing algorithm, configure and build libmemcached with the --enable-hash_hsieh. =item MEMCACHED_BEHAVIOR_DISTRIBUTION Using this you can enable different means of distributing values to servers. The default method is MEMCACHED_DISTRIBUTION_MODULA. You can enable consistent hashing by setting MEMCACHED_DISTRIBUTION_CONSISTENT. Consistent hashing delivers better distribution and allows servers to be added to the cluster with minimal cache losses. Currently MEMCACHED_DISTRIBUTION_CONSISTENT is an alias for the value MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA. =item MEMCACHED_BEHAVIOR_CACHE_LOOKUPS Memcached can cache named lookups so that DNS lookups are made only once. =item MEMCACHED_BEHAVIOR_SUPPORT_CAS Support CAS operations (this is not enabled by default at this point in the server since it imposes a slight performance penalty). =item MEMCACHED_BEHAVIOR_KETAMA Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA and the hash to MEMCACHED_HASH_MD5. =item MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED Sets the default distribution to MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA with the weighted support. and the hash to MEMCACHED_HASH_MD5. =item MEMCACHED_BEHAVIOR_KETAMA_HASH Sets the hashing algorithm for host mapping on continuum. The value can be set to either MEMCACHED_HASH_DEFAULT, MEMCACHED_HASH_MD5, MEMCACHED_HASH_CRC, MEMCACHED_HASH_FNV1_64, MEMCACHED_HASH_FNV1A_64, MEMCACHED_HASH_FNV1_32, and MEMCACHED_HASH_FNV1A_32. =item MEMCACHED_BEHAVIOR_KETAMA_COMPAT Sets the compatibility mode. The value can be set to either MEMCACHED_KETAMA_COMPAT_LIBMEMCACHED (this is the default) or MEMCACHED_KETAMA_COMPAT_SPY to be compatible with the SPY Memcached client for Java. =item MEMCACHED_BEHAVIOR_POLL_TIMEOUT Modify the timeout value that is used by poll(). The default value is -1. An signed int pointer must be passed to memcached_behavior_set() to change this value. For memcached_behavior_get() a signed int value will be cast and returned as the unsigned long long. =item MEMCACHED_BEHAVIOR_USER_DATA This allows you to store a pointer to a specifc piece of data. This can be retrieved from inside of memcached_fetch_execute(). Cloning a memcached_st will copy the pointer to the clone. This was deprecated in 0.14 in favor of memcached_callback_set(3). This will be removed in 0.15. =item MEMCACHED_BEHAVIOR_BUFFER_REQUESTS Enabling buffered IO causes commands to "buffer" instead of being sent. Any action that gets data causes this buffer to be be sent to the remote connection. Quiting the connection or closing down the connection will also cause the buffered data to be pushed to the remote connection. =item MEMCACHED_BEHAVIOR_VERIFY_KEY Enabling this will cause libmemcached(3) to test all keys to verify that they are valid keys. =item MEMCACHED_BEHAVIOR_SORT_HOSTS Enabling this will cause hosts that are added to be placed in the host list in sorted order. This will defeat consisten hashing. =item MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT In non-blocking mode this changes the value of the timeout during socket connection. =item MEMCACHED_BEHAVIOR_BINARY_PROTOCOL Enable the use of the binary protocol. Please note that you cannot toggle this flag on an open connection. =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT Set this value to enable the server be removed after continuous MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT times connection failure. =item MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK Set this value to tune the number of messages that may be sent before libmemcached should start to automatically drain the input queue. Setting this value to high, may cause libmemcached to deadlock (trying to send data, but the send will block because the input buffer in the kernel is full). =item MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK Set this value to tune the number of bytes that may be sent before libmemcached should start to automatically drain the input queue (need at least 10 IO requests sent without reading the input buffer). Setting this value to high, may cause libmemcached to deadlock (trying to send data, but the send will block because the input buffer in the kernel is full). =item MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH The binary protocol works a bit different than the textual protocol in that a multiget is implemented as a pipe of single get-operations which are sent to the server in a chunk. If you are using large multigets from your application, you may improve the latency of the gets by setting this value so you send out the first chunk of requests when you hit the specified limit. It allows the servers to start processing the requests to send the data back while the rest of the requests are created and sent to the server. =item MEMCACHED_BEHAVIOR_NOREPLY Set this value to specify that you really don't care about the result from your storage commands (set, add, replace, append, prepend). =item MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS If you just want "a poor mans HA", you may specify the numbers of replicas libmemcached should store of each item (on different servers). This replication does not dedicate certain memcached servers to store the replicas in, but instead it will store the replicas together with all of the other objects (on the 'n' next servers specified in your server list). =item MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ Allows randomizing the replica reads starting point. Normally the read is done from primary server and in case of miss the read is done from primary + 1, then primary + 2 all the way to 'n' replicas. If this option is set on the starting point of the replica reads is randomized between the servers. This allows distributing read load to multiple servers with the expense of more write traffic. =item MEMCACHED_BEHAVIOR_CORK Enable TCP_CORK behavior. This is only available as an option Linux. MEMCACHED_NO_SERVERS is returned if no servers are available to test with. MEMCACHED_NOT_SUPPORTED is returned if we were not able to determine if support was available. All other responses then MEMCACHED_SUCCESS report an error of some sort. This behavior also enables MEMCACHED_BEHAVIOR_TCP_NODELAY when set. =item MEMCACHED_BEHAVIOR_KEEPALIVE Enable TCP_KEEPALIVE behavior. =item MEMCACHED_BEHAVIOR_KEEPALIVE_IDLE Specify time, in seconds, to mark a connection as idle. This is only available as an option Linux. =item MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE Find the current size of SO_SNDBUF. A value of 0 means either an error occured or no hosts were available. It is safe to assume system default if this occurs. =item MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE Find the current size of SO_RCVBUF. A value of 0 means either an error occured or no hosts were available. It is safe to assume system default if this occurs. =item MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT This number of times a host can have an error before it is disabled. =item MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS If enabled any hosts which have been flagged as disabled will be removed from the list of servers in the memcached_st structure. This must be used in combination with MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT. =item MEMCACHED_BEHAVIOR_RETRY_TIMEOUT When enabled a host which is problematic will only be checked for usage based on the amount of time set by this behavior. =back =head1 RETURN memcached_behavior_get() returns either the current value of the get, or 0 or 1 on simple flag behaviors (1 being enabled). memcached_behavior_set() returns failure or success. =head1 NOTES memcached_behavior_set() in version .17 was changed from taking a pointer to data value, to taking a uin64_t. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_strerror.pm0000644000175000017500000000204012522723506026062 0ustar seanseanpackage Memcached::libmemcached::memcached_strerror; =head1 NAME memcached_strerror - Get error string =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include const char * memcached_strerror (memcached_st *ptr, memcached_return_t rc); =head1 DESCRIPTION memcached_strerror() takes a C value and returns a string describing the error. This string must not be modified by the application. C values are returned from nearly all libmemcached(3) functions. C values are of an enum type so that you can set up responses with switch/case and know that you are capturing all possible return values. =head1 RETURN memcached_strerror() returns a string describing a C value. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_server_st.pm0000644000175000017500000000537112522723506026226 0ustar seanseanpackage Memcached::libmemcached::memcached_server_st; =head1 NAME memcached_server_list_free, memcached_server_list_append, memcached_server_list_count, memcached_servers_parse - Manage server list =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include const memcached_server_instance_st memcached_server_list (memcached_st *ptr); void memcached_server_list_free (memcached_server_list_st list); memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error); uint32_t memcached_server_list_count (memcached_server_list_st list); memcached_server_list_st memcached_servers_parse (const char *server_strings); const char *memcached_server_error (memcached_server_instance_st instance); DEPRECATED void memcached_server_error_reset (memcached_server_instance_st list); =head1 DESCRIPTION libmemcached(3) operates on a list of hosts which are stored in memcached_server_st structures. You should not modify these structures directly. Functions are provided to modify these structures (and more can be added, just ask!). memcached_server_list() is used to provide an array of all defined hosts. This was incorrectly documented as "requiring free()" up till version 0.39. memcached_server_list_free() deallocates all memory associated with the array of memcached_server_st that you passed to it. memcached_server_list_append() adds a server to the end of a memcached_server_st array. On error null will be returned and the memcached_return_t pointer you passed into the function will be set with the appropriate error. If the value of port is zero, it is set to the default port of a memcached server. memcached_servers_parse() takes a string, the type that is used for the command line applications, and parse it to an array of memcached_server_st. The example is "localhost, foo:555, foo, bar". All hosts except foo:555 will be set to the default port, while that host will have a port of 555. memcached_server_error() can be used to look at the text of the last error message sent by the server to to the client. Before version 0.39 theses functions used a memcache_server_st *. In 0.39 memcached_server_st * was aliased to memcached_server_list_st. This was done for a style reason/to help clean up some concepts in the code. =head1 RETURN Varies, see particular functions. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_analyze.pm0000644000175000017500000000275012522723506025653 0ustar seanseanpackage Memcached::libmemcached::memcached_analyze; =head1 NAME memcached_analyze - Analyze server information =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_analysis_st * memcached_analyze (memcached_st *ptr, memcached_stat_st *stat, memcached_return_t *error); =head1 DESCRIPTION libmemcached(3) has the ability to query a memcached server (or collection of servers) for their current state. Queries to find state return a C structure. You are responsible for freeing this structure. memcached_analyze() analyzes useful information based on the provided servers and sets the result to the C structure. The return value must be freed by the calling application. A command line tool, memstat(1) with the option --analyze, is provided so that you do not have to write an application to use this method. =head1 RETURN A pointer to the allocated C structure on success and a NULL pointer on failure. You may inspect the error detail by checking the C value. Any method returning a C expects you to free the memory allocated for it. =head1 HOME To find out more information please check: L =head1 AUTHOR Toru Maesaka, Edev@torum.netE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_quit.pm0000644000175000017500000000241112522723506025164 0ustar seanseanpackage Memcached::libmemcached::memcached_quit; =head1 NAME memcached_quit - Disconnect from all servers =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include void memcached_quit (memcached_st *ptr); =head1 DESCRIPTION memcached_quit() will disconnect you from all currently connected servers. It will also reset the state of the connection (ie, any memcached_fetch() you are in the middle of will be terminated). This function is called automatically when you call memcached_free() on the C structure. You do not need to call this on your own. All operations to change server hashes and parameters will handle connections to the server for you. This function is provided mainly so that you can timeout your connections or reset connections during the middle of a memcached_fetch(). =head1 RETURN A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/API.pm0000644000175000017500000000516112522723506022632 0ustar seanseanpackage Memcached::libmemcached::API; =head1 NAME Memcached::libmemcached::API - Private volitile module =head1 SYNOPSIS use Memcached::libmemcached::API; @function_names = libmemcached_functions(); @constant_names = libmemcached_constants(); @EXPORT_TAGS = libmemcached_tags(); =head1 DESCRIPTION This module should be considered private. It may change or be removed in future. =head1 FUNCTIONS =cut use base qw(Exporter); our @EXPORT = qw( libmemcached_functions libmemcached_constants libmemcached_tags ); # load hash of libmemcached functions created by Makefile.PL my $libmemcached_funcs = require "Memcached/libmemcached/func_hash.pl"; die "Memcached/libmemcached/func_hash.pl failed sanity check" unless ref $libmemcached_funcs eq 'HASH' and keys %$libmemcached_funcs > 20; # extra functions provided by Memcached::libmemcached my %libmemcached_extra_functions = ( memcached_errstr => 1, memcached_mget_into_hashref => 1, memcached_set_callback_coderefs => 1, ); # functions we don't provide an API for my %libmemcached_unimplemented_functions = ( # memcached_server_st memcached_server_push => 0, memcached_servers_parse => 0, memcached_server_list_append => 0, memcached_server_list_free => 0, ); # build complete list of implemented functions our @libmemcached_funcs = do { my %funcs = ( %$libmemcached_funcs, %libmemcached_extra_functions, %libmemcached_unimplemented_functions ); grep { $funcs{$_} } sort keys %funcs; }; # load hash of libmemcached functions created by Makefile.PL my $libmemcached_consts = require "Memcached/libmemcached/const_hash.pl"; die "Memcached/libmemcached/const_hash.pl failed sanity check" unless ref $libmemcached_consts eq 'HASH' and keys %$libmemcached_consts > 20; our @libmemcached_consts = sort keys %$libmemcached_consts; =head2 libmemcached_functions @names = libmemcached_functions(); Returns a list of all the public functions in the libmemcached library. =cut sub libmemcached_functions { @libmemcached_funcs } =head2 libmemcached_constants @names = libmemcached_constants(); Returns a list of all the constants in the libmemcached library. =cut sub libmemcached_constants { @libmemcached_consts } =head2 libmemcached_tags @tags = libmemcached_tags(); Returns a hash list of pairs of tag name and array references suitable for setting %EXPORT_TAGS. =cut sub libmemcached_tags { my %tags; push @{ $tags{ $libmemcached_consts->{$_} } }, $_ for keys %$libmemcached_consts; #use Data::Dumper; warn Dumper(\%tags); return %tags; } 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_set.pm0000644000175000017500000001743312522723506025007 0ustar seanseanpackage Memcached::libmemcached::memcached_set; =head1 NAME memcached_set, memcached_add, memcached_replace - Store value on server =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_set (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_add (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_replace (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) memcached_return_t memcached_append(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) memcached_return_t memcached_cas(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas); memcached_return_t memcached_set_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_add_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_replace_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_prepend_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_append_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return_t memcached_cas_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas); =head1 DESCRIPTION memcached_set(), memcached_add(), and memcached_replace() are all used to store information on the server. All methods take a key, and its length to store the object. Keys are currently limited to 250 characters by the memcached(1) server. You must also supply a value and a length. Optionally you may support an expiration time for the object and a 16 byte value (it is meant to be used as a bitmap). memcached_set() will write an object to the server. If an object already exists it will overwrite what is in the server. If the object does not exist it will be written. If you are using the non-blocking mode this function will always return true unless a network error occurs. memcached_replace() replaces an object on the server. If the object is not found on the server an error occurs. memcached_add() adds an object to the server. If the object is found on the server an error occurs, otherwise the value is stored. memcached_prepend() places a segment of data before the last piece of data stored. Currently expiration and key are not used in the server. memcached_append() places a segment of data at the end of the last piece of data stored. Currently expiration and key are not used in the server. memcached_cas() overwrites data in the server as long as the "cas" value is still the same in the server. You can get the cas value of a result by calling memcached_result_cas() on a memcached_result_st(3) structure. At the point that this note was written cas is still buggy in memached. Turning on support for it in libmemcached(3) is optional. Please see memcached_set() for information on how to do this. memcached_set_by_key(), memcached_add_by_key(), memcached_replace_by_key(), memcached_prepend_by_key(), memcached_append_by_key_by_key(), memcached_cas_by_key() methods all behave in a similar method as the non key methods. The difference is that they use their master_key parameter to map objects to particular servers. If you are looking for performance, memcached_set() with non-blocking IO is the fastest way to store data on the server. All of the above functions are supported with the C behavior enabled. But when using these operations with this behavior on, there are limits to the size of the payload being sent to the server. The reason for these limits is that the Memcahed Server does not allow multi-datagram requests and the current server implementation sets a datagram size to 1400 bytes. Due to protocol overhead, the actual limit of the user supplied data is less than 1400 bytes and depends on the protocol in use as well as the operation being executed. When running with the binary protocol, C< MEMCACHED_BEHAVIOR_BINARY_PROTOCOL>, the size of the key,value, flags and expiry combined may not exceed 1368 bytes. When running with the ASCII protocol, the exact limit fluctuates depending on which function is being executed and whether the function is a cas operation or not. For non-cas ASCII set operations, there are at least 1335 bytes available to split among the key, key_prefix, and value; for cas ASCII operations there are at least 1318 bytes available to split among the key, key_prefix and value. If the total size of the command, including overhead, exceeds 1400 bytes, a C will be returned. =head1 RETURN All methods return a value of type C. On success the value will be C. Use memcached_strerror() to translate this value to a printable string. For memcached_replace() and memcached_add(), C is a legitmate error in the case of a collision. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_auto.pm0000644000175000017500000001312312522723506025154 0ustar seanseanpackage Memcached::libmemcached::memcached_auto; =head1 NAME memcached_increment, memcached_decrement, memcached_increment_with_initial, memcached_decrement_with_initial - Manipulate counters =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_increment (memcached_st *ptr, const char *key, size_t key_length, unsigned int offset, uint64_t *value); memcached_return_t memcached_decrement (memcached_st *ptr, const char *key, size_t key_length, unsigned int offset, uint64_t *value); memcached_return_t memcached_increment_with_initial (memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); memcached_return_t memcached_decrement_with_initial (memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); memcached_return_t memcached_increment_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, unsigned int offset, uint64_t *value); memcached_return_t memcached_decrement_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, unsigned int offset, uint64_t *value); memcached_return_t memcached_increment_with_initial_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); memcached_return_t memcached_decrement_with_initial_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t initial, time_t expiration, uint64_t *value); =head1 DESCRIPTION memcached(1) servers have the ability to increment and decrement keys (overflow and underflow are not detected). This gives you the ability to use memcached to generate shared sequences of values. memcached_increment() takes a key and keylength and increments the value by the offset passed to it. The value is then returned via the unsigned int value pointer you pass to it. memcached_decrement() takes a key and keylength and decrements the value by the offset passed to it. The value is then returned via the unsigned int value pointer you pass to it. memcached_increment_with_initial() takes a key and keylength and increments the value by the offset passed to it. If the object specified by key does not exist, one of two things may happen: If the expiration value is MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero.The value is then returned via the unsigned int value pointer you pass to it. memcached_decrement_with_initial() takes a key and keylength and decrements the value by the offset passed to it. If the object specified by key does not exist, one of two things may happen: If the expiration value is MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other expiration values, the operation will succeed by seeding the value for that key with a initial value to expire with the provided expiration time. The flags will be set to zero.The value is then returned via the unsigned int value pointer you pass to it. memcached_increment_by_key(), memcached_decrement_by_key(), memcached_increment_with_initial_by_key(), and memcached_decrement_with_initial_by_key() are master key equivalents of the above. =head1 RETURN A value of type C is returned. On success that value will be C. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/constants.pm0000644000175000017500000001167512527461455024253 0ustar seansean# DO NOT EDIT! GENERATED BY Makefile.PL =head1 NAME Memcached::libmemcached::constants - document list of constants defined by libmemcached =head1 DESCRIPTION This file just lists all the constants defined by libmemcached which are available to import via the L module. Each constant can be imported individually by name. Groups of related constants, such as the elements of an C type, can be imported as a set using a C<:tag> name. See L for more information about tags. =head1 TAGS =head2 :defines MEMCACHED_CONTINUUM_ADDITION MEMCACHED_CONTINUUM_SIZE MEMCACHED_DEFAULT_CONNECT_TIMEOUT MEMCACHED_DEFAULT_PORT MEMCACHED_DEFAULT_PORT_STRING MEMCACHED_DEFAULT_TIMEOUT MEMCACHED_EXPIRATION_NOT_ADD MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH MEMCACHED_MAX_BUFFER MEMCACHED_MAX_HOST_SORT_LENGTH MEMCACHED_MAX_KEY MEMCACHED_POINTS_PER_SERVER MEMCACHED_POINTS_PER_SERVER_KETAMA MEMCACHED_PREFIX_KEY_MAX_SIZE MEMCACHED_SERVER_FAILURE_DEAD_TIMEOUT MEMCACHED_SERVER_FAILURE_LIMIT MEMCACHED_SERVER_FAILURE_RETRY_TIMEOUT MEMCACHED_SERVER_TIMEOUT_LIMIT MEMCACHED_STRIDE MEMCACHED_VERSION_STRING_LENGTH =head2 :memcached_behavior_t MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS MEMCACHED_BEHAVIOR_BINARY_PROTOCOL MEMCACHED_BEHAVIOR_BUFFER_REQUESTS MEMCACHED_BEHAVIOR_CACHE_LOOKUPS MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT MEMCACHED_BEHAVIOR_CORK MEMCACHED_BEHAVIOR_DEAD_TIMEOUT MEMCACHED_BEHAVIOR_DISTRIBUTION MEMCACHED_BEHAVIOR_HASH MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK MEMCACHED_BEHAVIOR_KETAMA MEMCACHED_BEHAVIOR_KETAMA_HASH MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED MEMCACHED_BEHAVIOR_LOAD_FROM_FILE MEMCACHED_BEHAVIOR_MAX MEMCACHED_BEHAVIOR_NOREPLY MEMCACHED_BEHAVIOR_NO_BLOCK MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS MEMCACHED_BEHAVIOR_POLL_TIMEOUT MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ MEMCACHED_BEHAVIOR_RCV_TIMEOUT MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS MEMCACHED_BEHAVIOR_RETRY_TIMEOUT MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT MEMCACHED_BEHAVIOR_SND_TIMEOUT MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE MEMCACHED_BEHAVIOR_SORT_HOSTS MEMCACHED_BEHAVIOR_SUPPORT_CAS MEMCACHED_BEHAVIOR_TCP_KEEPALIVE MEMCACHED_BEHAVIOR_TCP_KEEPIDLE MEMCACHED_BEHAVIOR_TCP_NODELAY MEMCACHED_BEHAVIOR_USER_DATA MEMCACHED_BEHAVIOR_USE_UDP MEMCACHED_BEHAVIOR_VERIFY_KEY =head2 :memcached_callback_t MEMCACHED_CALLBACK_CLEANUP_FUNCTION MEMCACHED_CALLBACK_CLONE_FUNCTION MEMCACHED_CALLBACK_DELETE_TRIGGER MEMCACHED_CALLBACK_GET_FAILURE MEMCACHED_CALLBACK_MAX MEMCACHED_CALLBACK_NAMESPACE MEMCACHED_CALLBACK_PREFIX_KEY MEMCACHED_CALLBACK_USER_DATA =head2 :memcached_connection_t MEMCACHED_CONNECTION_TCP MEMCACHED_CONNECTION_UDP MEMCACHED_CONNECTION_UNIX_SOCKET =head2 :memcached_hash_t MEMCACHED_HASH_CRC MEMCACHED_HASH_CUSTOM MEMCACHED_HASH_DEFAULT MEMCACHED_HASH_FNV1A_32 MEMCACHED_HASH_FNV1A_64 MEMCACHED_HASH_FNV1_32 MEMCACHED_HASH_FNV1_64 MEMCACHED_HASH_HSIEH MEMCACHED_HASH_JENKINS MEMCACHED_HASH_MAX MEMCACHED_HASH_MD5 MEMCACHED_HASH_MURMUR MEMCACHED_HASH_MURMUR3 =head2 :memcached_return_t MEMCACHED_AUTH_CONTINUE MEMCACHED_AUTH_FAILURE MEMCACHED_AUTH_PROBLEM MEMCACHED_BAD_KEY_PROVIDED MEMCACHED_BUFFERED MEMCACHED_CLIENT_ERROR MEMCACHED_CONNECTION_BIND_FAILURE MEMCACHED_CONNECTION_FAILURE MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE MEMCACHED_DATA_DOES_NOT_EXIST MEMCACHED_DATA_EXISTS MEMCACHED_DELETED MEMCACHED_DEPRECATED MEMCACHED_E2BIG MEMCACHED_END MEMCACHED_ERRNO MEMCACHED_ERROR MEMCACHED_FAILURE MEMCACHED_FAIL_UNIX_SOCKET MEMCACHED_FETCH_NOTFINISHED MEMCACHED_HOST_LOOKUP_FAILURE MEMCACHED_INVALID_ARGUMENTS MEMCACHED_INVALID_HOST_PROTOCOL MEMCACHED_IN_PROGRESS MEMCACHED_ITEM MEMCACHED_KEY_TOO_BIG MEMCACHED_MAXIMUM_RETURN MEMCACHED_MEMORY_ALLOCATION_FAILURE MEMCACHED_NOTFOUND MEMCACHED_NOTSTORED MEMCACHED_NOT_SUPPORTED MEMCACHED_NO_KEY_PROVIDED MEMCACHED_NO_SERVERS MEMCACHED_PARSE_ERROR MEMCACHED_PARSE_USER_ERROR MEMCACHED_PARTIAL_READ MEMCACHED_PROTOCOL_ERROR MEMCACHED_READ_FAILURE MEMCACHED_SERVER_ERROR MEMCACHED_SERVER_MARKED_DEAD MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE MEMCACHED_SERVER_TEMPORARILY_DISABLED MEMCACHED_SOME_ERRORS MEMCACHED_STAT MEMCACHED_STORED MEMCACHED_SUCCESS MEMCACHED_TIMEOUT MEMCACHED_UNKNOWN_READ_FAILURE MEMCACHED_UNKNOWN_STAT_KEY MEMCACHED_VALUE MEMCACHED_WRITE_FAILURE =head2 :memcached_server_distribution_t MEMCACHED_DISTRIBUTION_CONSISTENT MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY MEMCACHED_DISTRIBUTION_CONSISTENT_MAX MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED MEMCACHED_DISTRIBUTION_MODULA MEMCACHED_DISTRIBUTION_RANDOM MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_delete.pm0000644000175000017500000000332012522723506025444 0ustar seanseanpackage Memcached::libmemcached::memcached_delete; =head1 NAME memcached_delete - Delete a key =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_delete (memcached_st *ptr, const char *key, size_t key_length, time_t expiration); memcached_return_t memcached_delete_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, time_t expiration); =head1 DESCRIPTION memcached_delete() is used to delete a particular key. memcached_delete_by_key() works the same, but it takes a master key to find the given value. Expiration works by placing the item into a delete queue, which means that it won't possible to retrieve it by the "get" command, but "add" and "replace" command with this key will also fail (the "set" command will succeed, however). After the time passes, the item is finally deleted from server memory. Please note the the Danga memcached server removed support for expiration in the 1.4 version. =head1 RETURN A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. If you are using the non-blocking mode of the library, success only means that the message was queued for delivery. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_dump.pm0000644000175000017500000000273412522723506025157 0ustar seanseanpackage Memcached::libmemcached::memcached_dump; =head1 NAME memcached_dump - get a list of keys found on memcached servers =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_dump (memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks); typedef memcached_return_t (*memcached_dump_fn)(memcached_st *ptr, const char *key, size_t key_length, void *context); =head1 DESCRIPTION memcached_dump() is used to get a list of keys found memcached(1) servers. Because memcached(1) does not guarentee to dump all keys you can not assume you have fetched all keys from the server. The function takes an array of callbacks that it will use to execute on keys as they are found. Currently the binar protocol is not supported. =head1 RETURN A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_create.pm0000644000175000017500000000424412522723506025453 0ustar seanseanpackage Memcached::libmemcached::memcached_create; =head1 NAME memcached_create, memcached_free, memcached_clone, memcached_servers_reset- Create a memcached_st structure =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_st *memcached_create (memcached_st *ptr); void memcached_free (memcached_st *ptr); memcached_st *memcached_clone (memcached_st *destination, memcached_st *source); void memcached_servers_reset(memcached_st); =head1 DESCRIPTION memcached_create() is used to create a C structure that will then be used by other libmemcached(3) functions to communicate with the server. You should either pass a statically declared C to memcached_create() or a NULL. If a NULL passed in then a structure is allocated for you. memcached_clone() is similar to memcached_create(3) but it copies the defaults and list of servers from the source C. If you pass a null as the argument for the source to clone, it is the same as a call to memcached_create(). If the destination argument is NULL a C will be allocated for you. memcached_servers_reset() allows you to zero out the list of servers that the memcached_st has. To clean up memory associated with a C structure you should pass it to memcached_free() when you are finished using it. memcached_free() is the only way to make sure all memory is deallocated when you finish using the structure. You may wish to avoid using memcached_create(3) or memcached_clone(3) with a stack based allocation. The most common issues related to ABI safety involve heap allocated structures. =head1 RETURN memcached_create() returns a pointer to the memcached_st that was created (or initialized). On an allocation failure, it returns NULL. memcached_clone() returns a pointer to the memcached_st that was created (or initialized). On an allocation failure, it returns NULL. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_flush.pm0000644000175000017500000000221112522723506025321 0ustar seanseanpackage Memcached::libmemcached::memcached_flush; =head1 NAME memcached_flush - wipe contents of memcached servers =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_return_t memcached_flush (memcached_st *ptr, time_t expiration); =head1 DESCRIPTION memcached_flush() is used to wipe clean the contents of memcached(1) servers. It will either do this immediately or expire the content based on the expiration time passed to the method (a value of zero causes an immediate flush). The operation is not atomic to multiple servers, just atomic to a single server. That is, it will flush the servers in the order that they were added. =head1 RETURN A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_stats.pm0000644000175000017500000000571112522723506025346 0ustar seanseanpackage Memcached::libmemcached::memcached_stats; =head1 NAME memcached_stat, memcached_stat_servername, memcached_stat_get_value, memcached_stat_get_keys - Get memcached statistics =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include memcached_stat_st *memcached_stat (memcached_st *ptr, char *args, memcached_return_t *error); memcached_return_t memcached_stat_servername (memcached_stat_st *stat, char *args, const char *hostname, unsigned int port); char * memcached_stat_get_value (memcached_st *ptr, memcached_stat_st *stat, const char *key, memcached_return_t *error); char ** memcached_stat_get_keys (memcached_st *ptr, memcached_stat_st *stat, memcached_return_t *error); =head1 DESCRIPTION libmemcached(3) has the ability to query a memcached server (or collection of servers) for their current state. Queries to find state return a C structure. You are responsible for freeing this structure. While it is possible to access the structure directly it is not advisable. structures containing the state of all available memcached servers. The return value must be freed by the calling application. If called with the C behavior set, a NULL value is returned and the error parameter is set to C. memcached_stat_servername() can be used standalone without a C to obtain the state of a particular server. "args" is used to define a particular state object (a list of these are not provided for by either the memcached_stat_get_keys() call nor are they defined in the memcached protocol). You must specify the hostname and port of the server you want to obtain information on. memcached_stat_get_value() returns the value of a particular state key. You specify the key you wish to obtain. The key must be null terminated. memcached_stat_get_keys() returns a list of keys that the server has state objects on. You are responsible for freeing this list. A command line tool, memstat(1), is provided so that you do not have to write an application to do this. =head1 RETURN Varies, see particular functions. Any method returning a C expects you to free the memory allocated for it. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_sasl.pm0000644000175000017500000000406712522723506025155 0ustar seanseanpackage Memcached::libmemcached::memcached_sasl; =head1 NAME memcached_set_sasl_callbacks, memcached_get_sasl_callbacks, memcached_sasl_set_auth_data, memcached_destroy_sasl_auth_data - SASL support =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include void memcached_set_sasl_callbacks(memcached_st *ptr, const sasl_callback_t *callbacks) const sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr) memcached_return memcached_set_sasl_auth_data(memcached_st *ptr, const char *username, const char *password) memcached_return memcached_destroy_sasl_auth_data(memcached_st *ptr) =head1 DESCRIPTION libmemcached(3) allows you to plug in your own callbacks function used by libsasl to perform SASL authentication. Please note that SASL requires the memcached binary protocol, and you have to specify the callbacks before you connect to the server. memcached_set_sasl_auth_data() is a helper function for you defining the basic functionality for you, but it will store the username and password in memory. If you choose to use this method you have to call memcached_destroy_sasl_auth_data before calling memcached_free to avoid a memory leak. You should NOT call memcached_destroy_sasl_auth_data if you specify your own callback function with memcached_set_sasl_callbacks(). You as a client user have to initialize libsasl by using sasl_client_init before enabling it in libmemcached, and you have to shut down libsasl by calling sasl_done() when you are done using SASL from libmemcached. =head1 RETURN memcached_get_sasl_callbacks() returns the callbacks currently used by this memcached handle. memcached_get_sasl_set_auth_data() returns MEMCACHED_SUCCESS upon success. =head1 HOME To find out more information please check: L =head1 AUTHOR Trond Norbye, Etrond.norbye@gmail.comE =head1 SEE ALSO memcached(1) libmemcached(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_generate_hash_value.pm0000644000175000017500000000315612522723506030202 0ustar seanseanpackage Memcached::libmemcached::memcached_generate_hash_value; =head1 NAME memcached_generate_hash_value - Hash a key value =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include uint32_t memcached_generate_hash_value (const char *key, size_t key_length, memcached_hash_t hash_algorithm); uint32_t memcached_generate_hash (memcached_st *ptr, const char *key, size_t key_length); =head1 DESCRIPTION memcached_generate_hash_value() allows you to hash a key using one of the hash functions defined in the library. This method is provided for the convenience of higher-level language bindings and is not necessary for normal memcache operations. The allowed hash algorithm constants are listed in the manpage for memcached_behavior_set(). memcached_generate_hash() takes a memcached_st struture and produces the hash value that would have been generated based on the defaults of the memcached_st structure. As of version 0.36 all hash methods have been placed into the library libhashkit(3) which is linked with libmemcached(3). =head1 RETURN A 32-bit integer which is the result of hashing the given key. For 64-bit hash algorithms, only the least-significant 32 bits are returned. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_behavior_set(3) libhashkit(3) =cut 1; Memcached-libmemcached-1.001801/lib/Memcached/libmemcached/memcached_servers.pm0000644000175000017500000001036312522723506025700 0ustar seanseanpackage Memcached::libmemcached::memcached_servers; =head1 NAME memcached_server_count, memcached_server_list, memcached_server_add, memcached_server_push, memcached_server_get_last_disconnect, memcached_server_cursor - Manage server list =head1 LIBRARY C Client Library for memcached (libmemcached, -lmemcached) =head1 SYNOPSIS #include uint32_t memcached_server_count (memcached_st *ptr); memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, in_port_t port); memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, in_port_t port); memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket); memcached_return_t memcached_server_push (memcached_st *ptr, const memcached_server_st *list); memcached_server_instance_st memcached_server_by_key (const memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error); memcached_server_instance_st memcached_server_get_last_disconnect (const memcached_st *ptr) memcached_return_t memcached_server_cursor(const memcached_st *ptr, const memcached_server_fn *callback, void *context, uint32_t number_of_callbacks); =head1 DESCRIPTION libmemcached(3) performs operations on a list of hosts. The order of these hosts determine routing to keys. Functions are provided to add keys to memcached_st structures. To manipulate lists of servers see memcached_server_st(3). memcached_server_count() provides you a count of the current number of servers being used by a C structure. memcached_server_add() pushes a single TCP server into the C structure. This server will be placed at the end. Duplicate servers are allowed, so duplication is not checked. Executing this function with the C behavior set will result in a C. memcached_server_add_udp() pushes a single UDP server into the C structure. This server will be placed at the end. Duplicate servers are allowed, so duplication is not checked. Executing this function with out setting the C behavior will result in a C. memcached_server_add_unix_socket() pushes a single UNIX socket into the C structure. This UNIX socket will be placed at the end. Duplicate servers are allowed, so duplication is not checked. The length of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH. memcached_server_push() pushes an array of C into the C structure. These servers will be placed at the end. Duplicate servers are allowed, so duplication is not checked. A copy is made of structure so the list provided (and any operations on the list) are not saved. memcached_server_by_key() allows you to provide a key and retrieve the server which would be used for assignment. This structure is cloned from its original structure and must be freed. If NULL is returned you should consult *error. The returning structure should be freed with memcached_server_free(). memcached_server_get_last_disconnect() returns a pointer to the last server for which there was a connection problem. It does not mean this particular server is currently dead but if the library is reporting a server is, the returned server is a very good candidate. memcached_server_cursor() takes a memcached_st and loops through the list of hosts currently in the cursor calling the list of callback functions provided. You can optionally pass in a value via context which will be provided to each callback function. An error return from any callback will terminate the loop. memcached_server_cursor() is passed the original caller memcached_st in its current state. =head1 RETURN Varies, see particular functions. =head1 HOME To find out more information please check: L =head1 AUTHOR Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO memcached(1) libmemcached(3) memcached_strerror(3) =cut 1; Memcached-libmemcached-1.001801/README.md0000644000175000017500000000544612522723506016137 0ustar seansean# Memcached-libmemcached [![Build Status](https://secure.travis-ci.org/timbunce/Memcached-libmemcached.png)](http://travis-ci.org/timbunce/Memcached-libmemcached/) Memcached::libmemcached is a very thin, highly efficient, wrapper around the libmemcached library. It gives full access to the rich functionality offered by libmemcached. libmemcached is fast, light on memory usage, thread safe, and provides full access to server side methods. - Synchronous and Asynchronous support. - TCP and Unix Socket protocols. - A half dozen or so different hash algorithms. - Implementations of the new cas, replace, and append operators. - Man pages written up on entire API. - Implements both modulo and consistent hashing solutions. # INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test (see TESTING below) make install Note that the "perl Makefile.PL" step will configure and build a private copy of libmemcached from source. So don't be surprised to see pages of output during that step. If you'd like to have the commandline tools that come with libmemcached installed, invoke Makefile.PL as: perl Makefile.PL --bin See http://libmemcached.org for details. # TESTING The "make test" command can run some tests without using a memcached server. Others are skipped unless a memcached server can be found. By default the tests look for a memcached server at the standard port on localhost. To use one or more other servers set the PERL_LIBMEMCACHED_TEST_SERVERS environment variable to a comma separated list of hostname:port values. Most tests require just one server but some require at least 5 servers. # SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Memcached::libmemcached You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Memcached-libmemcached AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Memcached-libmemcached CPAN Ratings http://cpanratings.perl.org/d/Memcached-libmemcached Search CPAN http://search.cpan.org/dist/Memcached-libmemcached # COPYRIGHT AND LICENCE Copyright (C) 2008, 2013 Tim Bunce This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. # DEVELOPER TOOLS Debugging make realclean # if perl Makefile.PL already run perl Makefile.PL -g Profiling make realclean # if perl Makefile.PL already run perl Makefile.PL -pg Test coverage analysis make realclean # if perl Makefile.PL already run perl Makefile.PL -cov make make testcover Install commandline tools from libmemcached perl Makefile.PL -bin make make install Memcached-libmemcached-1.001801/META.yml0000664000175000017500000000111512527462751016127 0ustar seansean--- abstract: 'Thin fast full interface to the libmemcached client API' author: - 'Tim Bunce ' build_requires: {} dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.120921' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Memcached-libmemcached no_index: directory: - t - inc resources: bugtracker: https://github.com/timbunce/Memcached-libmemcached/issues/ repository: git://github.com/timbunce/Memcached-libmemcached.git version: 1.001801 Memcached-libmemcached-1.001801/Changes0000644000175000017500000001233612522723506016147 0ustar seansean=head1 NAME Memcached::libmemcached::Changes - List of significant changes =head2 Changes in 1.001800 - 7th April 2014 Sync with libmemcached 1.0.18 =head2 Changes in 1.001702 - 14th March 2014 Change bug tracker to GitHub Fix link to current repository, also add to META. Thanks to dsteinbrunner Work around missing libcloog-ppl0 compilation issues, RT#88378 Improve handling of case where last_return==MEMCACHED_ERRNO but lmc_state->last_errno==0, RT#41299. =head2 Changes in 1.001701 - 2nd Sept 2013 Sync with libmemcached 1.0.17 Fixed links in docs, RT#66291 Fixed whatis in pod of Memcached::libmemcached::API, RT#71172 Fixed undef warnings related to expiration, RT#69996 Don't let DESTDIR env var upset libmemcached build (Chip Salzenberg). Note that get_server_for_key() may have a memory leak. =head2 Changes in 0.4406 4th Jan 2011 Added get_server_for_key() thanks to Roy Hooper. =head2 Changes in 0.4405 29th Oct 2010 Fix crash if memcached_callback_get(MEMCACHED_CALLBACK_PREFIX_KEY) returns NULL. =head2 Changes in 0.4404 28th Oct 2010 Added memcached_callback_set() to enable MEMCACHED_CALLBACK_PREFIX_KEY. Added memcached_callback_get() Made test timing more robust. =head2 Changes in 0.4403 28th Oct 2010 Changed memcached_version() to return the lowest server version seen. Added new memcached_{inc,dec}rement{_with_initial,}{_by_key,} methods. Added new methods memcached_server_add_with_weight() and memcached_server_add_unix_socket_with_weight(). Added new trace_level() method. =head2 Changes in 0.4402 26th Oct 2010 Changed walk_stats() API. Now uses the memcached_stat_execute() function and no longer passes $stats_arg as the forth argument to the callback. Minor updates to docs. =head2 Changes in 0.4401 21st Oct 2010 Sync with libmemcached 0.44 Fixed core dump in stats function. Fixed memory leak in stats function. RT#41496 Improved error reporting in trace log. =head2 Changes in 0.4202 2nd Aug 2010 Fix memcached_version() to properly return a list when called in list context this should resolve rt #59864 =head2 Changes in 0.4201 16th Jul 2010 Sync with libmemcached 0.42 Squashed various compile warnings Many updates to libmemcached API calls due to API changes Merged existing svn tree (which was out of sync) with Daisuke's tree =head2 Changes in 0.3101 6th Sep 2009 Sync with libmemcached 0.31 Now tested against memcached 1.4.1 Now tested with binary protocol Work with newer libmemcached, which returned MEMCACHED_END instead of MEMCACHED_SUCCESS on fetch success =head2 Changes in 0.2501 (svn r163) 17th Dec 2008 Sync with libmemcached 0.25. =head2 Changes in 0.2101 (svn r156) 27th May 2008 Sync with libmemcached 0.21. Report memcached version when running tests. Skip flags test when using memcached <1.2.4. Test consistent hashing thanks to Daisuke Maki. Deprecated undocumented calling get() with an array ref as key it now generates a warning. Added way to specify multiple memcached servers for tests. Added -bin option to Makefile.PL to install mem* utilities thanks to Jos Boumans. =head2 Changes in 0.1902 (svn r144) 17th April 2008 Fixed leak of $memc which prevented DESTROY (and thus memcached_free) being called, thanks to Jim Spath and Daisuke Maki. Fixed tests to not use whitespace in keys, thanks to Daisuke Maki. =head2 Changes in 0.1901 (svn r140) 10th April 2008 Sync with libmemcached 0.19. Added walk_stats method for fetching stats via a callback thanks to Daisuke Maki. =head2 Changes in 0.1701 (svn r129) 3rd March 2008 Sync with libmemcached 0.17. Perl API for memcached_version returns the version info. Added auto-generated Memcached::libmemcached::constants docs. Improved docs. Assorted minor fixes. =head2 Changes in 0.1405 (svn rXXX) Added official object-oriented API for perl-specific extensions. Allow SubclassName->new as alias for memcached_create. Deprecated perl-specific functions superceeded by methods: memcached_errstr - now $memc->errstr memcached_mget_into_hashref - now $memc->mget_into_hashref memcached_set_callback_coderefs - now $memc->set_callback_coderefs Added -g/-pg options to Makefile.PL to enable debug/profiling. Changed memcache object to be blessed hash instead of blessed int. =head2 Changes in 0.1404 (svn r106) 29th Jan 2008 Fixes for perl 5.6. Removed dependency on Time::HiRes for testing. =head2 Changes in 0.1402 (svn r102) 27th Jan 2008 Added tracing via PERL_LIBMEMCACHED_TRACE env var. Added perl callbacks for get and set. Added many more functions and improved the docs. Reenable perl 5.006 as we supply our own xsubpp now. =head2 Changes in 0.1401 Added memcached_errstr and related $memc state management. Changes functions to return simple boolean code. Added memcached_replace, memcached_cas More tests. =head2 Changes in 0.1308 Includes libmemcached-0.14 memcached_return values are now boolean (true, defined false, or undef) Added memcached_errstr($memc) to access last error code and string. Bundle xsubpp to avoid problems interfacing with our custom ParseXS. =head2 Changes in 0.1307 Min perl version now 5.008 due to XS length(other_arg) syntax. =cut Memcached-libmemcached-1.001801/responses.csv0000644000175000017500000000055612522723506017413 0ustar seansean::Fast,store,retrieve,delete,inc/dec,flush,version,nowait MATCH_OK,,,,,T,,T MATCH_STORED,T,,,,,,T MATCH_NOT_STORED,F,,,,,,T MATCH_EXISTS,F,,,,,,T MATCH_NOT_FOUND,F,,F,"""""",,,T MATCH_DELETED,,,T,,,,T MATCH_VERSION,,,,,,T,T NO_MATCH,,,,,,, MATCH_VALUE,,,,,,, MATCH_END,,T,,,,, MATCH_STAT,,,,,,, MATCH_ERROR,,,,,,, MATCH_CLIENT_ERROR,,,,,,, MATCH_SERVER_ERROR,,,,,,,