├── .gitignore ├── LICENSE.txt ├── Makefile ├── README.md ├── media ├── DPDKCap.svg ├── DPDKCapLogo_200x130.png └── DPDKCapLogo_400x260.png └── src ├── core_capture.c ├── core_capture.h ├── core_write.c ├── core_write.h ├── dpdkcap.c ├── lzo ├── lzowrite.c ├── lzowrite.h └── minilzo │ ├── README.LZO │ ├── lzoconf.h │ ├── lzodefs.h │ ├── minilzo.c │ └── minilzo.h ├── pcap.c ├── pcap.h ├── statistics.c ├── statistics.h ├── statistics_ncurses.c ├── utils.c └── utils.h /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD LICENSE 2 | 3 | Copyright(c) 2010-2015 Intel Corporation. All rights reserved. 4 | Copyright(c) 2015 University of Twente 5 | Copyright(c) 2015 Wouter de Vries 6 | Copyright(c) 2016 LAAS-CNRS 7 | Copyright(c) 2016 Gilles roudiere 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions 11 | are met: 12 | 13 | * Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in 17 | the documentation and/or other materials provided with the 18 | distribution. 19 | * Neither the name of Intel Corporation, LAAS-CNRS nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(RTE_SDK),) 2 | $(error "Please define RTE_SDK environment variable") 3 | endif 4 | 5 | # Default target, can be overridden by command line or environment 6 | RTE_TARGET ?= x86_64-native-linuxapp-gcc 7 | 8 | include $(RTE_SDK)/mk/rte.vars.mk 9 | 10 | # binary name 11 | APP=dpdkcap 12 | 13 | # all source are stored in SRCS-y 14 | SRC_DIR= src 15 | SOURCES= dpdkcap.c core_write.c core_capture.c statistics_ncurses.c pcap.c utils.c lzo/minilzo/minilzo.c lzo/lzowrite.c 16 | 17 | SRCS-y += $(addprefix $(SRC_DIR)/, $(SOURCES)) 18 | 19 | CFLAGS += -O3 -g $(WERROR_FLAGS) -Wfatal-errors 20 | LDLIBS += -lncurses 21 | 22 | include $(RTE_SDK)/mk/rte.extapp.mk 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # DPDKCap 6 | 7 | DPDKCap is packet capture tool based on DPDK. It provides a multi-port, 8 | multi-core optimized capture with on the fly compression. Thus particularly 9 | suiting captures at very high speed rates (more that 10Gpbs). 10 | 11 | ## 1. Installation and platform configuration 12 | 13 | ### 1.1 Install DPDK 14 | 15 | Please DPDK installation instruction, either from the [DPDK quick start 16 | instructions](http://dpdk.org/doc/quick-start) or from your operating system 17 | specific [Getting started 18 | guide](http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html). 19 | 20 | ### 1.2 Install dependencies 21 | 22 | DPDKCap requires the following dependencies to be built: 23 | - libncurses-dev 24 | 25 | ### 1.3 Build and Install DPDKCap 26 | 27 | To build DPDKCap, you first need to set `RTE_SDK` and `RTE_TARGET`. 28 | ``` 29 | $ export RTE_SDK=... # Replace by your DPDK install directory 30 | $ export RTE_TARGET=x86_64-native-linuxapp-gcc # Replace by your target 31 | ``` 32 | 33 | To build DPDKCap, run the following command into DPDKCap root directory: 34 | ``` 35 | $ make 36 | ``` 37 | 38 | ## 2. Usage 39 | 40 | DPDKCap works as a standard DPDK application. Thus it needs Environment 41 | Abstraction Layer (EAL) arguments before dpdkcap specific ones: 42 | 43 | ``` 44 | # ./build/dpdkcap [EAL args] -- [dpdkcap args] 45 | ``` 46 | 47 | Check out the [dpdk documentation](http://dpdk.org/doc/guides/index.html) for 48 | more information on EAL arguments. You will probably need the `-l` option for 49 | cores allocation and the `--huge-dir` one for providing huge pages directory. 50 | 51 | To get a list of DPDKCap specific available options, run: 52 | ``` 53 | # ./build/dpdkcap [EAL args] -- --help 54 | ``` 55 | 56 | ### 2.1 Selecting cores for capture 57 | 58 | From the available ports detected by DPDK, you can select ports to capture by 59 | using the `-p, --portmask` option. This option takes as argument an hexadecimal 60 | mask whose bits represent each port. By default, DPDKCap uses only the first 61 | port (portmask=0x1). 62 | 63 | For example, if you want to capture ports 1, 2 and 4, use: `--portmask 0xb` 64 | 65 | ### 2.2 Assigning tasks to lcores 66 | 67 | DPDKCap assigns two different tasks to lcores: 68 | - Capturing cores enqueue packets from Ethernet ports queues into a main 69 | buffer. Each captured port must be assigned at least a core. 70 | - Writing cores extract packets from this buffer and write them into LZO 71 | compressed pcap capture files. Each writing core writes into a different 72 | file. 73 | 74 | As a consequence, DPDKCap needs, at least, a single writing core and as many 75 | capturing cores as ports you want to capture. Finally, a last lcore must be 76 | kept to handle logs and statistics. However, depending on your traffic 77 | bandwidth and your system capabilities, you might need to use more cores. 78 | 79 | The `-c, --per_port_c_cores` option allocates `NB_CORES_PER_PORT` capturing 80 | cores **per selected port**. 81 | 82 | The `-w, --num_w_cores` option allocates a **total** of `NB_CORES` writing 83 | cores. 84 | 85 | Note that the writing task requires more computational power than the capture 86 | one (due to compression), thus you will probably need to allow more writing 87 | cores than capture ones. This being said, size your storage system accordingly, 88 | as thousands cores could not achieve a full capture with a too low storage 89 | system bandwidth. 90 | 91 | ### 2.3 Limiting file size or duration 92 | 93 | Depending on the data you want to capture, you might need to split the capture 94 | into several files. Two options are available to limit file size/duration: 95 | - The `-G, --rotate_seconds` option creates a new file every `T` seconds. 96 | - The `-C, --limit_file_size` option creates a new file when the current file 97 | size goes over the specified `SIZE`. 98 | 99 | You can specify the output file template using the `-o, --output` option. This 100 | is necessary with the `-G, --rotate_seconds` option if you do not want to erase 101 | the same file again and again. See the following section. 102 | 103 | ### 2.4 Setting output template 104 | 105 | The `-o,--output` let you provide a template for the output file. This template 106 | is formatted according to the following tokens: 107 | 108 | - `%COREID` this is replaced by the writing core id into the filename. This 109 | token is mandatory and will be automatically appended to the output file 110 | template if not present. 111 | 112 | - `%FCOUNT` this is replaced by a counter that allows distinguishing files 113 | created by the `-C, --limit_file_size` option. If this option is used, this 114 | token is mandatory and will be automatically appended to the output file 115 | template if not present. 116 | 117 | - Date *strftime* tokens. These tokens are replaced according to *strftime* 118 | standard. This date is updated every time the `-G, --rotate_seconds` option 119 | triggers a file change. These tokens are not mandatory with this option, but 120 | you might overwrite previously created files. 121 | 122 | ### 2.5 Other options 123 | - `-s, --snaplen` limits the packet capture to LENGTH bytes. 124 | - `-S, --statistics` prints a set of statistics while the capture is 125 | running. 126 | - `--logs` output logs into the specified file instead of stderr. 127 | - `--no-compression` disables the LZO compression. This is not advised, as it 128 | greatly increase the disk I/O. It can however be used for capturing low speed 129 | traffic. 130 | 131 | ## 3. Software License Agreements 132 | 133 | DPDKCap is distributed under the BSD License, see LICENSE.txt. 134 | 135 | -------------------------------------------------------------------------------- /media/DPDKCapLogo_200x130.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Woutifier/dpdkcap/5a465e36ed7c0d396e978a303e2b1b168d93a92e/media/DPDKCapLogo_200x130.png -------------------------------------------------------------------------------- /media/DPDKCapLogo_400x260.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Woutifier/dpdkcap/5a465e36ed7c0d396e978a303e2b1b168d93a92e/media/DPDKCapLogo_400x260.png -------------------------------------------------------------------------------- /src/core_capture.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "core_capture.h" 10 | 11 | #define RTE_LOGTYPE_DPDKCAP RTE_LOGTYPE_USER1 12 | 13 | /* 14 | * Capture the traffic from the given port/queue tuple 15 | */ 16 | int capture_core(const struct core_capture_config * config) { 17 | struct rte_mbuf *bufs[DPDKCAP_CAPTURE_BURST_SIZE]; 18 | uint16_t nb_rx; 19 | int nb_rx_enqueued; 20 | 21 | RTE_LOG(INFO, DPDKCAP, "Core %u is capturing packets for port %u\n", 22 | rte_lcore_id(), config->port); 23 | 24 | /* Init stats */ 25 | *(config->stats) = (struct core_capture_stats) { 26 | .core_id=rte_lcore_id(), 27 | .packets = 0, 28 | .missed_packets = 0, 29 | }; 30 | 31 | /* Run until the application is quit or killed. */ 32 | for (;;) { 33 | /* Stop condition */ 34 | if (unlikely(*(config->stop_condition))) { 35 | break; 36 | } 37 | 38 | /* Retrieve packets and put them into the ring */ 39 | nb_rx = rte_eth_rx_burst(config->port, config->queue, 40 | bufs, DPDKCAP_CAPTURE_BURST_SIZE); 41 | if (likely(nb_rx > 0)) { 42 | nb_rx_enqueued = rte_ring_enqueue_bulk(config->ring, (void*) bufs, 43 | nb_rx); 44 | 45 | /* Update stats */ 46 | if(nb_rx_enqueued == 0 || nb_rx_enqueued == -EDQUOT) { 47 | config->stats->packets+=nb_rx; 48 | } else { 49 | config->stats->missed_packets+=nb_rx; 50 | /* Free whatever we can't put in the write ring */ 51 | for (nb_rx_enqueued=0; nb_rx_enqueued < nb_rx; nb_rx_enqueued++) { 52 | rte_pktmbuf_free(bufs[nb_rx_enqueued]); 53 | } 54 | } 55 | } 56 | } 57 | 58 | RTE_LOG(INFO, DPDKCAP, "Closed capture core %d (port %d)\n", 59 | rte_lcore_id(), config->port); 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /src/core_capture.h: -------------------------------------------------------------------------------- 1 | #ifndef DPDKCAP_CORE_CAPTURE_H 2 | #define DPDKCAP_CORE_CAPTURE_H 3 | 4 | #include 5 | 6 | #define DPDKCAP_CAPTURE_BURST_SIZE 256 7 | 8 | /* Core configuration structures */ 9 | struct core_capture_config { 10 | struct rte_ring * ring; 11 | bool volatile * stop_condition; 12 | struct core_capture_stats * stats; 13 | uint8_t port; 14 | uint8_t queue; 15 | }; 16 | 17 | /* Statistics structure */ 18 | struct core_capture_stats { 19 | int core_id; 20 | uint64_t packets; //Packets successfully enqueued 21 | uint64_t missed_packets; //Packets core could not enqueue 22 | }; 23 | 24 | /* Launches a capture task */ 25 | int capture_core(const struct core_capture_config * config); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/core_write.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "lzo/lzowrite.h" 15 | #include "pcap.h" 16 | #include "utils.h" 17 | 18 | #include "core_write.h" 19 | 20 | #define MIN(a,b) (((a)<(b))?(a):(b)) 21 | 22 | #define RTE_LOGTYPE_DPDKCAP RTE_LOGTYPE_USER1 23 | 24 | /* 25 | * Change file name from template 26 | */ 27 | static void format_from_template( 28 | char * filename, 29 | const char * template, 30 | const int core_id, 31 | const int file_count, 32 | const struct timeval * file_start 33 | ) { 34 | char str_buf[DPDKCAP_OUTPUT_FILENAME_LENGTH]; 35 | //Change file name 36 | strncpy(filename, template, 37 | DPDKCAP_OUTPUT_FILENAME_LENGTH); 38 | snprintf(str_buf, 50, "%02d", core_id); 39 | while(str_replace(filename,"\%COREID",str_buf)); 40 | snprintf(str_buf, 50, "%03d", file_count); 41 | while(str_replace(filename,"\%FCOUNT",str_buf)); 42 | strncpy(str_buf, filename, DPDKCAP_OUTPUT_FILENAME_LENGTH); 43 | #pragma GCC diagnostic push 44 | #pragma GCC diagnostic ignored "-Wformat-nonliteral" 45 | strftime(filename, DPDKCAP_OUTPUT_FILENAME_LENGTH, str_buf, 46 | localtime(&(file_start->tv_sec))); 47 | #pragma GCC diagnostic pop 48 | } 49 | 50 | /* 51 | * Open pcap file for writing 52 | */ 53 | static FILE * open_pcap(char * output_file) { 54 | FILE * file; 55 | //Open file 56 | file = fopen(output_file,"w"); 57 | if (unlikely(!file)) { 58 | RTE_LOG(ERR, DPDKCAP, "Core %d could not open %s in write mode: %d (%s)\n", 59 | rte_lcore_id(), output_file, errno, strerror(errno)); 60 | } 61 | 62 | return file; 63 | } 64 | 65 | /* 66 | * Write into a pcap file 67 | */ 68 | static int write_pcap(FILE * file, void * src, size_t len) { 69 | size_t retval; 70 | // Write file 71 | retval = fwrite(src, len, 1, file); 72 | if (unlikely(retval != 1)) { 73 | RTE_LOG(ERR, DPDKCAP, "Could not write into file: %d (%s)\n", 74 | errno, strerror(errno)); 75 | return -1; 76 | } 77 | return retval; 78 | } 79 | 80 | /* 81 | * Close and free a pcap file 82 | */ 83 | static int close_pcap(FILE * file) { 84 | int retval; 85 | // Close file 86 | retval = fclose(file); 87 | if (unlikely(retval)) { 88 | RTE_LOG(ERR, DPDKCAP, "Could not close file: %d (%s)\n", 89 | errno, strerror(errno)); 90 | } 91 | return retval; 92 | } 93 | 94 | /* 95 | * Allocates a new lzowrite_buffer from the given file 96 | */ 97 | static struct lzowrite_buffer * open_lzo_pcap(char * output_file) { 98 | struct lzowrite_buffer * buffer; 99 | FILE * file; 100 | 101 | //Open file 102 | file = fopen(output_file,"w"); 103 | if (unlikely(!file)) { 104 | RTE_LOG(ERR, DPDKCAP, "Core %d could not open %s in write mode: %d (%s)\n", 105 | rte_lcore_id(), output_file, errno, strerror(errno)); 106 | goto cleanup; 107 | } 108 | 109 | //Init lzo file 110 | buffer = lzowrite_init(file); 111 | if(unlikely(!buffer)) { 112 | RTE_LOG(ERR, DPDKCAP, "Core %d could not init lzo in file: %s\n", 113 | rte_lcore_id(), output_file); 114 | goto cleanup_file; 115 | } 116 | 117 | return buffer; 118 | cleanup_file: 119 | fclose(file); 120 | cleanup: 121 | return NULL; 122 | } 123 | 124 | /* 125 | * Free a lzowrite_buffer 126 | */ 127 | static int close_lzo_pcap(struct lzowrite_buffer * buffer) { 128 | FILE * file = buffer->output; 129 | int retval; 130 | 131 | /* Closes the lzo buffer */ 132 | retval = lzowrite_close(buffer); 133 | if (unlikely(retval)) { 134 | RTE_LOG(ERR, DPDKCAP, "Could not close lzowrite_buffer.\n"); 135 | return retval; 136 | } 137 | 138 | /* Close file */ 139 | retval = fclose(file); 140 | if (unlikely(retval)) { 141 | RTE_LOG(ERR, DPDKCAP, "Could not close file: %d (%s)\n", 142 | errno, strerror(errno)); 143 | return retval; 144 | } 145 | 146 | return 0; 147 | } 148 | 149 | /* 150 | * Write the packets form the write ring into a pcap compressed file 151 | */ 152 | int write_core(const struct core_write_config * config) { 153 | void * write_buffer; 154 | unsigned int packet_length, wire_packet_length, compressed_length; 155 | unsigned int remaining_bytes; 156 | int to_write; 157 | int bytes_to_write; 158 | struct rte_mbuf * dequeued[DPDKCAP_WRITE_BURST_SIZE]; 159 | struct rte_mbuf * bufptr; 160 | struct pcap_packet_header header; 161 | struct timeval tv; 162 | struct pcap_header pcp; 163 | int retval = 0; 164 | int written; 165 | void * (*file_open_func)(char*); 166 | int (*file_write_func)(void*, void *, int); 167 | int (*file_close_func)(void*); 168 | 169 | char file_name[DPDKCAP_OUTPUT_FILENAME_LENGTH]; 170 | unsigned int file_count = 0; 171 | uint64_t file_size = 0; 172 | struct timeval file_start; 173 | 174 | if(config->no_compression) { 175 | file_open_func = (void*(*)(char*)) open_pcap; 176 | file_write_func = (int (*)(void*, void*, int)) write_pcap; 177 | file_close_func = (int (*)(void*)) close_pcap; 178 | } else { 179 | file_open_func = (void*(*)(char*)) open_lzo_pcap; 180 | file_write_func = (int (*)(void*, void*, int)) lzowrite; 181 | file_close_func = (int (*)(void*)) close_lzo_pcap; 182 | } 183 | gettimeofday(&file_start, NULL); 184 | 185 | //Update filename 186 | format_from_template(file_name, config->output_file_template, 187 | rte_lcore_id(), file_count, &file_start); 188 | 189 | //Init stats 190 | *(config->stats) = (struct core_write_stats) { 191 | .core_id=rte_lcore_id(), 192 | .current_file_packets=0, 193 | .current_file_bytes=0, 194 | .current_file_compressed_bytes=0, 195 | .packets = 0, 196 | .bytes = 0, 197 | .compressed_bytes = 0, 198 | }; 199 | memcpy(config->stats->output_file, file_name, 200 | DPDKCAP_OUTPUT_FILENAME_LENGTH); 201 | 202 | //Init the common pcap header 203 | pcap_header_init(&pcp, config->snaplen); 204 | 205 | //Open new file 206 | write_buffer = file_open_func(file_name); 207 | if(unlikely(!write_buffer)) { 208 | retval = -1; 209 | goto cleanup; 210 | } 211 | 212 | //Write pcap header 213 | written = file_write_func(write_buffer, (unsigned char *) &pcp, sizeof(struct pcap_header)); 214 | if(unlikely(written<0)) { 215 | retval = -1; 216 | goto cleanup; 217 | } 218 | file_size = written; 219 | 220 | //Log 221 | RTE_LOG(INFO, DPDKCAP, "Core %d is writing using file template: %s.\n", 222 | rte_lcore_id(), config->output_file_template); 223 | 224 | for (;;) { 225 | if (unlikely(*(config->stop_condition) && rte_ring_empty(config->ring))) { 226 | break; 227 | } 228 | 229 | //Get packets from the ring 230 | to_write = rte_ring_dequeue_bulk(config->ring, (void*) dequeued, 231 | DPDKCAP_WRITE_BURST_SIZE); 232 | if (likely(to_write==0)) { 233 | to_write = DPDKCAP_WRITE_BURST_SIZE; 234 | } else { 235 | to_write = rte_ring_dequeue_burst(config->ring, (void*)dequeued, 236 | DPDKCAP_WRITE_BURST_SIZE); 237 | } 238 | 239 | //Update stats 240 | config->stats->packets += to_write; 241 | 242 | int i; 243 | bool file_changed; 244 | for (i = 0; i < to_write; i++) { 245 | //Cast to packet 246 | bufptr = dequeued[i]; 247 | wire_packet_length = rte_pktmbuf_pkt_len(bufptr); 248 | 249 | //Truncate packet if needed 250 | packet_length = MIN(config->snaplen, wire_packet_length); 251 | 252 | //Get time 253 | gettimeofday(&tv, NULL); 254 | 255 | //Create a new file according to limits 256 | file_changed = 0; 257 | if(config->rotate_seconds && 258 | (uint32_t)(tv.tv_sec-file_start.tv_sec) >= config->rotate_seconds) { 259 | file_count=0; 260 | gettimeofday(&file_start, NULL); 261 | file_changed=1; 262 | } 263 | if(config->file_size_limit && file_size >= config->file_size_limit) { 264 | file_count++; 265 | file_changed=1; 266 | } 267 | 268 | //Open new file 269 | if(file_changed) { 270 | //Change file name 271 | format_from_template(file_name, config->output_file_template, 272 | rte_lcore_id(), file_count, &file_start); 273 | 274 | //Update stats 275 | config->stats->current_file_packets = 0; 276 | config->stats->current_file_bytes = 0; 277 | memcpy(config->stats->output_file, file_name, 278 | DPDKCAP_OUTPUT_FILENAME_LENGTH); 279 | 280 | //Close pcap file and open new one 281 | file_close_func(write_buffer); 282 | 283 | //Reopen a file 284 | write_buffer = file_open_func(file_name); 285 | if(unlikely(!write_buffer)) { 286 | retval = -1; 287 | goto cleanup; 288 | } 289 | 290 | //Write pcap header 291 | written = file_write_func(write_buffer, &pcp, 292 | sizeof(struct pcap_header)); 293 | if(unlikely(written<0)) { 294 | retval = -1; 295 | goto cleanup; 296 | } 297 | //Reset file size 298 | file_size = written; 299 | } 300 | 301 | //Write block header 302 | header.timestamp = (int32_t) tv.tv_sec; 303 | header.microseconds = (int32_t) tv.tv_usec; 304 | header.packet_length = packet_length; 305 | header.packet_length_wire = wire_packet_length; 306 | written = file_write_func(write_buffer, &header, 307 | sizeof(struct pcap_packet_header)); 308 | if (unlikely(written<0)) { 309 | retval = -1; 310 | goto cleanup; 311 | } 312 | file_size += written; 313 | 314 | //Write content 315 | remaining_bytes = packet_length; 316 | compressed_length = 0; 317 | while (bufptr != NULL && remaining_bytes > 0) { 318 | bytes_to_write = MIN(rte_pktmbuf_data_len(bufptr), remaining_bytes); 319 | written = file_write_func(write_buffer, 320 | rte_pktmbuf_mtod(bufptr, void*), 321 | bytes_to_write); 322 | if (unlikely(written<0)) { 323 | retval = -1; 324 | goto cleanup; 325 | } 326 | bufptr = bufptr->next; 327 | remaining_bytes -= bytes_to_write; 328 | compressed_length += written; 329 | file_size += written; 330 | } 331 | 332 | //Free buffer 333 | rte_pktmbuf_free(dequeued[i]); 334 | 335 | //Update stats 336 | config->stats->bytes += packet_length; 337 | config->stats->compressed_bytes += compressed_length; 338 | config->stats->current_file_packets ++; 339 | config->stats->current_file_bytes += packet_length; 340 | config->stats->current_file_compressed_bytes = file_size; 341 | 342 | } 343 | } 344 | 345 | cleanup: 346 | //Close pcap file 347 | file_close_func(write_buffer); 348 | 349 | RTE_LOG(INFO, DPDKCAP, "Closed writing core %d\n", rte_lcore_id()); 350 | 351 | return retval; 352 | } 353 | -------------------------------------------------------------------------------- /src/core_write.h: -------------------------------------------------------------------------------- 1 | #ifndef DPDKCAP_CORE_WRITE_H 2 | #define DPDKCAP_CORE_WRITE_H 3 | 4 | #include 5 | #include 6 | 7 | #define DPDKCAP_OUTPUT_FILENAME_LENGTH 100 8 | #define DPDKCAP_WRITE_BURST_SIZE 256 9 | 10 | /* Writing core configuration */ 11 | struct core_write_config { 12 | struct rte_ring * ring; 13 | bool volatile * stop_condition; 14 | struct core_write_stats * stats; 15 | char * output_file_template; 16 | int no_compression; 17 | unsigned int snaplen; 18 | unsigned long rotate_seconds; 19 | uint64_t file_size_limit; 20 | }; 21 | 22 | /* Statistics structure */ 23 | struct core_write_stats { 24 | int core_id; 25 | char output_file[DPDKCAP_OUTPUT_FILENAME_LENGTH]; 26 | uint64_t current_file_packets; 27 | uint64_t current_file_bytes; 28 | uint64_t current_file_compressed_bytes; 29 | uint64_t packets; 30 | uint64_t bytes; 31 | uint64_t compressed_bytes; 32 | }; 33 | 34 | /* Launches a write task */ 35 | int write_core(const struct core_write_config * config); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/dpdkcap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "pcap.h" 13 | #include "core_write.h" 14 | #include "core_capture.h" 15 | #include "statistics.h" 16 | 17 | #define NUM_MBUFS 2048 18 | #define MBUF_CACHE_SIZE 256 //0 19 | #define WRITE_RING_SIZE NUM_MBUFS 20 | 21 | #define MAX_LCORES 1000 22 | 23 | #define DPDKCAP_OUTPUT_TEMPLATE_LENGTH 2 * DPDKCAP_OUTPUT_FILENAME_LENGTH 24 | 25 | #define RTE_LOGTYPE_DPDKCAP RTE_LOGTYPE_USER1 26 | 27 | /* ARGP */ 28 | const char *argp_program_version = "dpdkcap 1.1"; 29 | const char *argp_program_bug_address = "w.b.devries@utwente.nl"; 30 | static char doc[] = "A DPDK-based packet capture tool"; 31 | static char args_doc[] = ""; 32 | static struct argp_option options[] = { 33 | { "output", 'o', "FILE", 0, "Output FILE template (don't add the "\ 34 | "extension). Use \"\%COREID\" for inserting the lcore id into the file " \ 35 | "name (automatically added if not used). (default: output_\%COREID)" 36 | , 0 }, 37 | { "statistics", 'S', 0, 0, "Print statistics every few seconds.", 0 }, 38 | { "per_port_c_cores", 'c', "NB_CORES_PER_PORT", 0, "Number of cores per " \ 39 | "port used for capture (default: 1)", 0 }, 40 | { "num_w_cores", 'w', "NB_CORES", 0, "Total number of cores used for "\ 41 | "writing (default: 1).", 0 }, 42 | { "rotate_seconds", 'G', "T", 0, "Create a new set of files every T "\ 43 | "seconds. Use strftime formats within the output file template to rename "\ 44 | "each file accordingly.", 0}, 45 | { "limit_file_size", 'C', "SIZE", 0, "Before writing a packet, check "\ 46 | "whether the target file excess SIZE bytes. If so, creates a new file. " \ 47 | "Use \"\%FCOUNT\" within the output file template to index each new "\ 48 | "file.", 0}, 49 | { "portmask", 'p', "PORTMASK", 0, "Ethernet ports mask (default: 0x1).", 0 }, 50 | { "snaplen", 's', "LENGTH", 0, "Snap the capture to snaplen bytes "\ 51 | "(default: 65535).", 0 }, 52 | { "logs", 700, "FILE", 0, "Writes the logs into FILE instead of "\ 53 | "stderr.", 0 }, 54 | { "no-compression", 701, 0, 0, "Do not compress capture files.", 0 }, 55 | { 0 } }; 56 | 57 | struct arguments { 58 | char* args[2]; 59 | char output_file_template[DPDKCAP_OUTPUT_FILENAME_LENGTH]; 60 | uint64_t portmask; 61 | int statistics; 62 | unsigned int per_port_c_cores; 63 | unsigned int num_w_cores; 64 | int no_compression; 65 | unsigned int snaplen; 66 | unsigned int rotate_seconds; 67 | uint64_t file_size_limit; 68 | char * log_file; 69 | }; 70 | 71 | static error_t parse_opt(int key, char* arg, struct argp_state *state) { 72 | struct arguments* arguments = state->input; 73 | char *end; 74 | 75 | switch (key) { 76 | case 'p': 77 | /* parse hexadecimal string */ 78 | errno = 0; // strtoul does not fix errno to 0 on success 79 | arguments->portmask = strtoul(arg, &end, 16); 80 | if (errno != 0 || *end != '\0' || 81 | (arguments->portmask == ULONG_MAX && errno == ERANGE)) { 82 | RTE_LOG(ERR, DPDKCAP, "Invalid portmask '%s' (could not convert to "\ 83 | "unsigned long)\n", arg); 84 | return EINVAL; 85 | } 86 | if (arguments->portmask == 0) { 87 | RTE_LOG(ERR, DPDKCAP, "Invalid portmask '%s', no port used\n", arg); 88 | return EINVAL; 89 | } 90 | break; 91 | case 'o': 92 | strncpy(arguments->output_file_template,arg, 93 | DPDKCAP_OUTPUT_FILENAME_LENGTH); 94 | break; 95 | case 'S': 96 | arguments->statistics = 1; 97 | break; 98 | case 'c': 99 | arguments->per_port_c_cores = atoi(arg); 100 | break; 101 | case 'w': 102 | arguments->num_w_cores = atoi(arg); 103 | break; 104 | case 's': 105 | arguments->snaplen = atoi(arg); 106 | break; 107 | case 'G': 108 | arguments->rotate_seconds = atoi(arg); 109 | break; 110 | case 'C': 111 | arguments->file_size_limit = atoll(arg); 112 | break; 113 | case 700: 114 | arguments->log_file = arg; 115 | break; 116 | case 701: 117 | arguments->no_compression = 1; 118 | break; 119 | default: 120 | return ARGP_ERR_UNKNOWN; 121 | } 122 | return 0; 123 | } 124 | static struct argp argp = { options, parse_opt, args_doc, doc, 0, 0, 0 }; 125 | /* END OF ARGP */ 126 | 127 | static struct rte_ring *write_ring; 128 | 129 | struct arguments arguments; 130 | 131 | static unsigned int portlist[64]; 132 | static unsigned int nb_ports; 133 | 134 | static struct core_write_stats * cores_stats_write_list; 135 | static struct core_capture_stats* cores_stats_capture_list; 136 | 137 | static const struct rte_eth_conf port_conf_default = { 138 | .rxmode = { 139 | .mq_mode = ETH_MQ_RX_NONE, 140 | .max_rx_pkt_len = ETHER_MAX_LEN, 141 | } 142 | }; 143 | 144 | /* 145 | * Initializes a given port using global settings and with the RX buffers 146 | * coming from the mbuf_pool passed as a parameter. 147 | */ 148 | static int port_init( 149 | uint8_t port, 150 | const uint16_t rx_rings, 151 | struct rte_mempool *mbuf_pool) { 152 | 153 | struct rte_eth_conf port_conf = port_conf_default; 154 | struct rte_eth_dev_info dev_info; 155 | int retval; 156 | uint16_t q; 157 | 158 | /* Get the device info */ 159 | rte_eth_dev_info_get(port, &dev_info); 160 | 161 | /* Configure multiqueue (Activate Receive Side Scaling on UDP/TCP fields) */ 162 | if (rx_rings > 1) { 163 | port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS; 164 | port_conf.rx_adv_conf.rss_conf.rss_key = NULL; 165 | port_conf.rx_adv_conf.rss_conf.rss_hf = ETH_RSS_PROTO_MASK; 166 | } 167 | 168 | if (port >= rte_eth_dev_count()) { 169 | RTE_LOG(ERR, DPDKCAP, "Port identifier %d over the limit (max:%d)\n", port, 170 | rte_eth_dev_count()-1); 171 | return -1; 172 | } 173 | 174 | /* Configure the Ethernet device. */ 175 | retval = rte_eth_dev_configure(port, rx_rings, 1, &port_conf); 176 | if (retval != 0) { 177 | RTE_LOG(ERR, DPDKCAP, "rte_eth_dev_configure(...) returned with error "\ 178 | "code %d\n", retval); 179 | return retval; 180 | } 181 | 182 | /* Allocate and set up RX queues. */ 183 | for (q = 0; q < rx_rings; q++) { 184 | retval = rte_eth_rx_queue_setup(port, q, dev_info.rx_desc_lim.nb_max, 185 | rte_eth_dev_socket_id(port), NULL, mbuf_pool); 186 | if (retval < 0) { 187 | RTE_LOG(ERR, DPDKCAP, "rte_eth_rx_queue_setup(...) returned with error "\ 188 | "code %d\n", retval); 189 | return retval; 190 | } 191 | //Stats bindings 192 | retval = rte_eth_dev_set_rx_queue_stats_mapping (port, q, q); 193 | if (retval != 0) { 194 | RTE_LOG(WARNING, DPDKCAP, "rte_eth_dev_set_rx_queue_stats_mapping(...) "\ 195 | "returned with error code %d\n", retval); 196 | RTE_LOG(WARNING, DPDKCAP, "The queues statistics mapping failed. The "\ 197 | "displayed queue statistics are thus unreliable.\n"); 198 | } 199 | } 200 | 201 | /* Allocate one TX queue (unused) */ 202 | retval = rte_eth_tx_queue_setup(port, 0, dev_info.tx_desc_lim.nb_min, 203 | rte_eth_dev_socket_id(port),NULL); 204 | if (retval < 0) { 205 | RTE_LOG(ERR, DPDKCAP, "rte_eth_tx_queue_setup(...) "\ 206 | "returned with error code %d\n", retval); 207 | return retval; 208 | } 209 | /* Enable RX in promiscuous mode for the Ethernet device. */ 210 | rte_eth_promiscuous_enable(port); 211 | 212 | /* Display the port MAC address. */ 213 | struct ether_addr addr; 214 | rte_eth_macaddr_get(port, &addr); 215 | RTE_LOG(INFO, DPDKCAP, "Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8 216 | " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n", (unsigned) port, 217 | addr.addr_bytes[0], addr.addr_bytes[1], addr.addr_bytes[2], 218 | addr.addr_bytes[3], addr.addr_bytes[4], addr.addr_bytes[5]); 219 | 220 | return 0; 221 | } 222 | 223 | /* 224 | * Starts given port 225 | */ 226 | static int port_start(uint8_t port) { 227 | int retval = 0; 228 | /* Start the Ethernet port. */ 229 | retval = rte_eth_dev_start(port); 230 | return retval; 231 | } 232 | 233 | 234 | /* 235 | * Handles signals 236 | */ 237 | static volatile bool should_stop = false; 238 | static void signal_handler(int sig) { 239 | RTE_LOG(NOTICE, DPDKCAP, "Caught signal %s on core %u%s\n", 240 | strsignal(sig), rte_lcore_id(), 241 | rte_get_master_lcore()==rte_lcore_id()?" (MASTER CORE)":""); 242 | should_stop = true; 243 | } 244 | 245 | /* 246 | * The main function, which does initialization and calls the per-lcore 247 | * functions. 248 | */ 249 | int main(int argc, char *argv[]) { 250 | signal(SIGINT, signal_handler); 251 | struct core_capture_config * cores_config_capture_list; 252 | struct core_write_config * cores_config_write_list; 253 | unsigned int lcoreid_list[MAX_LCORES]; 254 | unsigned int nb_lcores; 255 | struct rte_mempool *mbuf_pool; 256 | unsigned int port_id; 257 | unsigned int i,j; 258 | unsigned int required_cores; 259 | unsigned int core_index; 260 | int result; 261 | FILE * log_file; 262 | 263 | /* Initialize the Environment Abstraction Layer (EAL). */ 264 | int ret = rte_eal_init(argc, argv); 265 | if (ret < 0) 266 | rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); 267 | 268 | argc -= ret; 269 | argv += ret; 270 | 271 | /* Parse arguments */ 272 | arguments = (struct arguments) { 273 | .statistics = 0, 274 | .per_port_c_cores = 1, 275 | .num_w_cores = 1, 276 | .no_compression = 0, 277 | .snaplen = PCAP_SNAPLEN_DEFAULT, 278 | .portmask = 0x1, 279 | .rotate_seconds = 0, 280 | .file_size_limit = 0, 281 | .log_file=NULL, 282 | }; 283 | strncpy(arguments.output_file_template,"output_\%COREID", 284 | DPDKCAP_OUTPUT_FILENAME_LENGTH); 285 | argp_parse(&argp, argc, argv, 0, 0, &arguments); 286 | 287 | /* Set log level */ 288 | rte_set_log_type(RTE_LOGTYPE_DPDKCAP, 1); 289 | rte_set_log_level(RTE_LOG_DEBUG); 290 | 291 | /* Change log stream if needed */ 292 | if(arguments.log_file) { 293 | log_file = fopen(arguments.log_file, "w"); 294 | if(!log_file) { 295 | rte_exit(EXIT_FAILURE, "Error: Could not open log file: (%d) %s\n", 296 | errno, strerror(errno)); 297 | } 298 | result=rte_openlog_stream(log_file); 299 | if(result) { 300 | rte_exit(EXIT_FAILURE, "Error: Could not change log stream: (%d) %s\n", 301 | errno, strerror(errno)); 302 | } 303 | } 304 | 305 | /* Add suffixes to output if needed */ 306 | if (!strstr(arguments.output_file_template,"\%COREID")) 307 | strcat(arguments.output_file_template,"_\%COREID"); 308 | if (arguments.file_size_limit && 309 | !strstr(arguments.output_file_template,"\%FCOUNT")) 310 | strcat(arguments.output_file_template,"_\%FCOUNT"); 311 | 312 | strcat(arguments.output_file_template, ".pcap"); 313 | 314 | if(!arguments.no_compression) 315 | strcat(arguments.output_file_template, ".lzo"); 316 | 317 | 318 | 319 | /* Check if one port is available */ 320 | if (rte_eth_dev_count() == 0) 321 | rte_exit(EXIT_FAILURE, "Error: No port available.\n"); 322 | 323 | /* Creates the port list */ 324 | nb_ports = 0; 325 | for (i = 0; i < 64; i++) { 326 | if (! ((uint64_t)(1ULL << i) & arguments.portmask)) 327 | continue; 328 | if (iring = write_ring; 386 | config->stop_condition = &should_stop; 387 | config->stats = &(cores_stats_write_list[i]); 388 | config->output_file_template = arguments.output_file_template; 389 | config->no_compression = arguments.no_compression; 390 | config->snaplen = arguments.snaplen; 391 | config->rotate_seconds = arguments.rotate_seconds; 392 | config->file_size_limit = arguments.file_size_limit; 393 | 394 | //Launch writing core 395 | if (rte_eal_remote_launch((lcore_function_t *) write_core, 396 | config, core_index) < 0) 397 | rte_exit(EXIT_FAILURE, "Could not launch writing process on lcore %d.\n", 398 | core_index); 399 | 400 | //Add the core to the list 401 | lcoreid_list[nb_lcores] = core_index; 402 | nb_lcores++; 403 | 404 | core_index = rte_get_next_lcore(core_index, SKIP_MASTER, 0); 405 | } 406 | 407 | /* For each port */ 408 | for (i = 0; i < nb_ports; i++) { 409 | port_id = portlist[i]; 410 | 411 | /* Port init */ 412 | int retval = port_init(port_id, arguments.per_port_c_cores, mbuf_pool); 413 | if (retval != 0) { 414 | rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8 "\n", port_id); 415 | } 416 | 417 | /* Capturing cores */ 418 | for (j=0; jring = write_ring; 423 | config->stop_condition = &should_stop; 424 | config->stats = 425 | &(cores_stats_capture_list[i*arguments.per_port_c_cores+j]); 426 | config->port = port_id; 427 | config->queue = j; 428 | //Launch capture core 429 | if (rte_eal_remote_launch((lcore_function_t *) capture_core, 430 | config, core_index) < 0) 431 | rte_exit(EXIT_FAILURE, "Could not launch capture process on lcore "\ 432 | "%d.\n",core_index); 433 | 434 | //Add the core to the list 435 | lcoreid_list[nb_lcores] = core_index; 436 | nb_lcores++; 437 | 438 | core_index = rte_get_next_lcore(core_index, SKIP_MASTER, 0); 439 | } 440 | 441 | /* Start the port once everything is ready to capture */ 442 | retval = port_start(port_id); 443 | if (retval != 0) { 444 | rte_exit(EXIT_FAILURE, "Cannot start port %"PRIu8 "\n", port_id); 445 | } 446 | } 447 | 448 | //Initialize statistics timer 449 | struct stats_data sd = { 450 | .ring = write_ring, 451 | .cores_stats_write_list = cores_stats_write_list, 452 | .cores_write_stats_list_size = arguments.num_w_cores, 453 | .cores_stats_capture_list = cores_stats_capture_list, 454 | .cores_capture_stats_list_size = arguments.per_port_c_cores*nb_ports, 455 | .port_list=portlist, 456 | .port_list_size=nb_ports, 457 | .queue_per_port=arguments.per_port_c_cores, 458 | .log_file=arguments.log_file, 459 | }; 460 | 461 | if (arguments.statistics && !should_stop) { 462 | signal(SIGINT, SIG_DFL); 463 | //End the capture when the interface returns 464 | start_stats_display(&sd); 465 | should_stop=true; 466 | } 467 | 468 | //Wait for all the cores to complete and exit 469 | RTE_LOG(NOTICE, DPDKCAP, "Waiting for all cores to exit\n"); 470 | for(i=0;i 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "minilzo/minilzo.h" 14 | 15 | #define RTE_LOGTYPE_LZO RTE_LOGTYPE_USER2 16 | 17 | #define HEAP_ALLOC(var,size) \ 18 | lzo_align_t __LZO_MMODEL var \ 19 | [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ] 20 | 21 | static int lzowrite_wbuf(struct lzowrite_buffer* lzowrite_buffer) { 22 | struct __attribute__((__packed__)) { 23 | uint32_t len; 24 | uint32_t out_length; 25 | } block_header; 26 | unsigned char out_buffer[LZOWRITE_OUT_BUFFER_SIZE]; 27 | uint32_t out_length; 28 | int to_be_written; 29 | int retval; 30 | 31 | if(lzowrite_buffer->length == 0) return 0; 32 | 33 | lzo1x_1_compress( 34 | lzowrite_buffer->buffer, lzowrite_buffer->length, 35 | out_buffer, (lzo_uintp)&(out_length), 36 | lzowrite_buffer->workmemory); 37 | 38 | //Write block_header header 39 | block_header.len = __bswap_32(lzowrite_buffer->length); 40 | if(lzowrite_buffer->length <= out_length) { 41 | block_header.out_length = __bswap_32(lzowrite_buffer->length); 42 | } else { 43 | block_header.out_length = __bswap_32(out_length); 44 | } 45 | retval = fwrite(&block_header, sizeof(block_header), 1, lzowrite_buffer->output); 46 | //Check if no write error occured 47 | if (unlikely(retval != 1)) { 48 | RTE_LOG(ERR, LZO, "Could not write lzo block header in file: %d (%s)\n", 49 | errno, strerror(errno)); 50 | retval=-1; 51 | } 52 | 53 | //Write data 54 | if(lzowrite_buffer->length <= out_length) { 55 | to_be_written = lzowrite_buffer->length; 56 | retval = fwrite(lzowrite_buffer->buffer, sizeof(unsigned char), 57 | to_be_written, lzowrite_buffer->output); 58 | } else { 59 | to_be_written = out_length; 60 | retval = fwrite(out_buffer, sizeof(unsigned char), 61 | to_be_written, lzowrite_buffer->output); 62 | } 63 | //Check if no write error occured 64 | if (unlikely(retval != to_be_written)) { 65 | RTE_LOG(ERR, LZO, "Could not write lzo block data in file: %d (%s)\n", 66 | errno, strerror(errno)); 67 | retval=-1; 68 | } 69 | 70 | //Reset buffer 71 | lzowrite_buffer->length = 0; 72 | 73 | return sizeof(block_header) + to_be_written ; 74 | } 75 | 76 | struct lzowrite_buffer * lzowrite_init(FILE* file) { 77 | static int initialized = 0; 78 | int status; 79 | 80 | /* To be written */ 81 | struct __attribute__((__packed__)) { 82 | const char magic[LZOWRITE_LZO_MAGIC_LEN]; 83 | struct lzowrite_file_header lzoheader; 84 | } fheader = { 85 | .magic = LZOWRITE_LZO_MAGIC, 86 | }; 87 | struct lzowrite_buffer * buffer = NULL; 88 | int written; 89 | 90 | //Initialize minilzo if needed 91 | if(!initialized) { 92 | status = lzo_init(); 93 | if (status) { 94 | RTE_LOG(ERR, LZO, "Could not initialize minilzo: %d\n", 95 | status); 96 | return NULL; 97 | } 98 | initialized = 1; 99 | } 100 | 101 | //Prepare the buffers 102 | if (unlikely(!file || !__fwritable(file))) { 103 | RTE_LOG(ERR, LZO, "Could not write into stream (NULL or unwritable)\n"); 104 | goto cleanup; 105 | } 106 | buffer = (struct lzowrite_buffer *) malloc (sizeof(struct lzowrite_buffer)); 107 | buffer->output = file; 108 | buffer->length = 0; 109 | 110 | //Allocate workmemory 111 | HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS); 112 | buffer->workmemory = wrkmem; 113 | 114 | //Init header 115 | fheader.lzoheader = (struct lzowrite_file_header) { 116 | .version = LZOWRITE_LZO_VERSION, 117 | .library_version = lzo_version(), 118 | .needed_version = LZOWRITE_LZO_VERSION_NEEDED_TO_EXTRACT, 119 | .compression_method = LZOWRITE_LZO_METHOD, 120 | .compression_level = LZOWRITE_LZO_COMPRESSION_LEVEL, 121 | .compression_flags = LZOWRITE_LZO_FLAGS, 122 | .mode = LZOWRITE_LZO_MODE, 123 | .file_mtime_low = 0, 124 | .file_mtime_high = 0, 125 | .file_name_length = 0, 126 | .file_header_checksum = 1, 127 | }; 128 | //Calculate checksum 129 | fheader.lzoheader.file_header_checksum = 130 | __bswap_32(lzo_adler32(fheader.lzoheader.file_header_checksum, 131 | (lzo_bytep)(&fheader.lzoheader), 132 | sizeof(struct lzowrite_file_header) - sizeof(uint32_t))); 133 | 134 | //Write file header 135 | written = fwrite(&fheader, sizeof(fheader), 1, buffer->output); 136 | if (unlikely(written != 1)) { 137 | RTE_LOG(ERR, LZO, "Could not write lzo file header in file: %d (%s)\n", 138 | errno, strerror(errno)); 139 | goto cleanup; 140 | } 141 | 142 | return buffer; 143 | 144 | cleanup: 145 | free(buffer); 146 | return NULL; 147 | } 148 | 149 | int lzowrite(struct lzowrite_buffer* lzowrite_buffer, void * src, size_t len) { 150 | int retval = 0; 151 | 152 | if (len > LZOWRITE_BUFFER_SIZE) { 153 | RTE_LOG(ERR, LZO, "Data bigger than buffer!\n"); 154 | retval = -1; 155 | goto cleanup; 156 | } 157 | 158 | if (lzowrite_buffer->length + len >= LZOWRITE_BUFFER_SIZE) { 159 | retval=lzowrite_wbuf(lzowrite_buffer); 160 | if (unlikely(retval < 0)) { 161 | retval= -1; 162 | } 163 | } 164 | 165 | memcpy(&(lzowrite_buffer->buffer[lzowrite_buffer->length]), src, len); 166 | lzowrite_buffer->length += len; 167 | cleanup: 168 | return retval; 169 | } 170 | 171 | int lzowrite_close(struct lzowrite_buffer* lzowrite_buffer) { 172 | unsigned char zeros[4] = {0}; 173 | int retval = 0; 174 | int written; 175 | 176 | /* Write remaining data */ 177 | written = lzowrite_wbuf(lzowrite_buffer); 178 | if(written < 0) { 179 | RTE_LOG(ERR, LZO, "Could not write remaining data.\n"); 180 | retval = -1; 181 | goto cleanup; 182 | } 183 | 184 | /* Write 4 zero bytes */ 185 | written = fwrite(zeros, sizeof(unsigned char), 4, lzowrite_buffer->output); 186 | if (unlikely(written != 4)) { 187 | RTE_LOG(ERR, LZO, "Could not write 4 zeros in file: %d (%s)\n", 188 | errno, strerror(errno)); 189 | retval = -1; 190 | goto cleanup; 191 | } 192 | 193 | cleanup: 194 | free(lzowrite_buffer); 195 | return retval; 196 | } 197 | -------------------------------------------------------------------------------- /src/lzo/lzowrite.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "minilzo/minilzo.h" 5 | 6 | #define LZOWRITE_BUFFER_SIZE 32 * 1024 7 | #define LZOWRITE_OUT_BUFFER_SIZE (LZOWRITE_BUFFER_SIZE + LZOWRITE_BUFFER_SIZE / 16 + 64 + 3) 8 | #define LZOWRITE_LZO_MAGIC {0x89,0x4c,0x5a,0x4f,0x00,0x0d,0x0a,0x1a,0x0a} 9 | #define LZOWRITE_LZO_MAGIC_LEN 9 10 | #define LZOWRITE_LZO_VERSION 0x3010 // as in LZOP 1.03 11 | #define LZOWRITE_LZO_LIB_VERSION (lzo_version() & 0xffff) 12 | #define LZOWRITE_LZO_VERSION_NEEDED_TO_EXTRACT 0x4009 // not using filters, otherwise 0x0950 13 | #define LZOWRITE_LZO_METHOD 1 // LZO1X 14 | #define LZOWRITE_LZO_COMPRESSION_LEVEL 1 // with lzo, we have compression level = 1. 15 | #define LZOWRITE_LZO_FLAGS 0 // no checksums on data!! 16 | #define LZOWRITE_LZO_MODE 0xa481 // 100644 oct 17 | 18 | void fwrite_int32_be(void* ptr, FILE* out); 19 | 20 | 21 | struct lzowrite_buffer { 22 | unsigned char buffer[LZOWRITE_BUFFER_SIZE]; 23 | uint32_t length; 24 | FILE* output; 25 | lzo_align_t* workmemory; 26 | }; 27 | 28 | struct __attribute__((__packed__)) lzowrite_file_header { 29 | uint16_t version; 30 | uint16_t library_version; 31 | uint16_t needed_version; 32 | uint8_t compression_method; 33 | uint8_t compression_level; 34 | uint32_t compression_flags; 35 | uint32_t mode; 36 | uint32_t file_mtime_low; 37 | uint32_t file_mtime_high; 38 | uint8_t file_name_length; 39 | uint32_t file_header_checksum; 40 | }; 41 | 42 | struct __attribute__((__packed__)) lzowrite_block_header { 43 | uint32_t uncompressed_size; 44 | uint32_t compressed_size; 45 | uint32_t uncompressed_adler32; 46 | uint32_t uncompressed_crc32; 47 | uint32_t compressed_adler32; 48 | uint32_t compressed_crc32; 49 | }; 50 | 51 | /* 52 | * Inits an lzo buffer with the given output file 53 | * Returns the buffer on success, NULL on error 54 | */ 55 | struct lzowrite_buffer * lzowrite_init(FILE *); 56 | 57 | /* 58 | * Writes len bytes from src into the given lzowrite_buffer 59 | * Returns the number of written bytes on success (might be 0), 60 | * -1 on failure. 61 | */ 62 | int lzowrite(struct lzowrite_buffer* lzowrite_buffer, void * src, 63 | size_t len); 64 | 65 | /* 66 | * Flushes the buffer by writting the last bytes into the output stream, then 67 | * close it. lzowrite_buffer should be freed at the end. 68 | * Returns 0 on success, -1 on failure. 69 | */ 70 | int lzowrite_close(struct lzowrite_buffer* lzowrite_buffer); 71 | -------------------------------------------------------------------------------- /src/lzo/minilzo/README.LZO: -------------------------------------------------------------------------------- 1 | 2 | ============================================================================ 3 | miniLZO -- mini subset of the LZO real-time data compression library 4 | ============================================================================ 5 | 6 | Author : Markus Franz Xaver Johannes Oberhumer 7 | 8 | http://www.oberhumer.com/opensource/lzo/ 9 | Version : 2.09 10 | Date : 04 Feb 2015 11 | 12 | I've created miniLZO for projects where it is inconvenient to 13 | include (or require) the full LZO source code just because you 14 | want to add a little bit of data compression to your application. 15 | 16 | miniLZO implements the LZO1X-1 compressor and both the standard and 17 | safe LZO1X decompressor. Apart from fast compression it also useful 18 | for situations where you want to use pre-compressed data files (which 19 | must have been compressed with LZO1X-999). 20 | 21 | miniLZO consists of one C source file and three header files: 22 | minilzo.c 23 | minilzo.h, lzoconf.h, lzodefs.h 24 | 25 | To use miniLZO just copy these files into your source directory, add 26 | minilzo.c to your Makefile and #include minilzo.h from your program. 27 | Note: you also must distribute this file ('README.LZO') with your project. 28 | 29 | minilzo.o compiles to about 6 KiB (using gcc or Visual C on an i386), and 30 | the sources are about 30 KiB when packed with zip - so there's no more 31 | excuse that your application doesn't support data compression :-) 32 | 33 | For more information, documentation, example programs and other support 34 | files (like Makefiles and build scripts) please download the full LZO 35 | package from 36 | http://www.oberhumer.com/opensource/lzo/ 37 | 38 | Have fun, 39 | Markus 40 | 41 | 42 | P.S. minilzo.c is generated automatically from the LZO sources and 43 | therefore functionality is completely identical 44 | 45 | 46 | Appendix A: building miniLZO 47 | ---------------------------- 48 | miniLZO is written such a way that it should compile and run 49 | out-of-the-box on most machines. 50 | 51 | If you are running on a very unusual architecture and lzo_init() fails then 52 | you should first recompile with '-DLZO_DEBUG' to see what causes the failure. 53 | The most probable case is something like 'sizeof(void *) != sizeof(size_t)'. 54 | After identifying the problem you can compile by adding some defines 55 | like '-DSIZEOF_VOID_P=8' to your Makefile. 56 | 57 | The best solution is (of course) using Autoconf - if your project uses 58 | Autoconf anyway just add '-DMINILZO_HAVE_CONFIG_H' to your compiler 59 | flags when compiling minilzo.c. See the LZO distribution for an example 60 | how to set up configure.ac. 61 | 62 | 63 | Appendix B: list of public functions available in miniLZO 64 | --------------------------------------------------------- 65 | Library initialization 66 | lzo_init() 67 | 68 | Compression 69 | lzo1x_1_compress() 70 | 71 | Decompression 72 | lzo1x_decompress() 73 | lzo1x_decompress_safe() 74 | 75 | Checksum functions 76 | lzo_adler32() 77 | 78 | Version functions 79 | lzo_version() 80 | lzo_version_string() 81 | lzo_version_date() 82 | 83 | Portable (but slow) string functions 84 | lzo_memcmp() 85 | lzo_memcpy() 86 | lzo_memmove() 87 | lzo_memset() 88 | 89 | 90 | Appendix C: suggested macros for 'configure.ac' when using Autoconf 91 | ------------------------------------------------------------------- 92 | Checks for typedefs and structures 93 | AC_CHECK_TYPE(ptrdiff_t,long) 94 | AC_TYPE_SIZE_T 95 | AC_CHECK_SIZEOF(short) 96 | AC_CHECK_SIZEOF(int) 97 | AC_CHECK_SIZEOF(long) 98 | AC_CHECK_SIZEOF(long long) 99 | AC_CHECK_SIZEOF(__int64) 100 | AC_CHECK_SIZEOF(void *) 101 | AC_CHECK_SIZEOF(size_t) 102 | AC_CHECK_SIZEOF(ptrdiff_t) 103 | 104 | Checks for compiler characteristics 105 | AC_C_CONST 106 | 107 | Checks for library functions 108 | AC_CHECK_FUNCS(memcmp memcpy memmove memset) 109 | 110 | 111 | Appendix D: Copyright 112 | --------------------- 113 | LZO and miniLZO are Copyright (C) 1996-2015 Markus Franz Xaver Oberhumer 114 | All Rights Reserved. 115 | 116 | LZO and miniLZO are distributed under the terms of the GNU General 117 | Public License (GPL). See the file COPYING. 118 | 119 | Special licenses for commercial and other applications which 120 | are not willing to accept the GNU General Public License 121 | are available by contacting the author. 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/lzo/minilzo/lzoconf.h: -------------------------------------------------------------------------------- 1 | /* lzoconf.h -- configuration of the LZO data compression library 2 | 3 | This file is part of the LZO real-time data compression library. 4 | 5 | Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer 6 | All Rights Reserved. 7 | 8 | The LZO library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of 11 | the License, or (at your option) any later version. 12 | 13 | The LZO library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with the LZO library; see the file COPYING. 20 | If not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | Markus F.X.J. Oberhumer 24 | 25 | http://www.oberhumer.com/opensource/lzo/ 26 | */ 27 | 28 | 29 | #ifndef __LZOCONF_H_INCLUDED 30 | #define __LZOCONF_H_INCLUDED 1 31 | 32 | #define LZO_VERSION 0x2090 33 | #define LZO_VERSION_STRING "2.09" 34 | #define LZO_VERSION_DATE "Feb 04 2015" 35 | 36 | /* internal Autoconf configuration file - only used when building LZO */ 37 | #if defined(LZO_HAVE_CONFIG_H) 38 | # include 39 | #endif 40 | #include 41 | #include 42 | 43 | 44 | /*********************************************************************** 45 | // LZO requires a conforming 46 | ************************************************************************/ 47 | 48 | #if !defined(CHAR_BIT) || (CHAR_BIT != 8) 49 | # error "invalid CHAR_BIT" 50 | #endif 51 | #if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) 52 | # error "check your compiler installation" 53 | #endif 54 | #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) 55 | # error "your limits.h macros are broken" 56 | #endif 57 | 58 | /* get OS and architecture defines */ 59 | #ifndef __LZODEFS_H_INCLUDED 60 | #include 61 | #endif 62 | 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | 69 | /*********************************************************************** 70 | // some core defines 71 | ************************************************************************/ 72 | 73 | /* memory checkers */ 74 | #if !defined(__LZO_CHECKER) 75 | # if defined(__BOUNDS_CHECKING_ON) 76 | # define __LZO_CHECKER 1 77 | # elif defined(__CHECKER__) 78 | # define __LZO_CHECKER 1 79 | # elif defined(__INSURE__) 80 | # define __LZO_CHECKER 1 81 | # elif defined(__PURIFY__) 82 | # define __LZO_CHECKER 1 83 | # endif 84 | #endif 85 | 86 | 87 | /*********************************************************************** 88 | // integral and pointer types 89 | ************************************************************************/ 90 | 91 | /* lzo_uint must match size_t */ 92 | #if !defined(LZO_UINT_MAX) 93 | # if (LZO_ABI_LLP64) 94 | # if (LZO_OS_WIN64) 95 | typedef unsigned __int64 lzo_uint; 96 | typedef __int64 lzo_int; 97 | # define LZO_TYPEOF_LZO_INT LZO_TYPEOF___INT64 98 | # else 99 | typedef lzo_ullong_t lzo_uint; 100 | typedef lzo_llong_t lzo_int; 101 | # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG_LONG 102 | # endif 103 | # define LZO_SIZEOF_LZO_INT 8 104 | # define LZO_UINT_MAX 0xffffffffffffffffull 105 | # define LZO_INT_MAX 9223372036854775807LL 106 | # define LZO_INT_MIN (-1LL - LZO_INT_MAX) 107 | # elif (LZO_ABI_IP32L64) /* MIPS R5900 */ 108 | typedef unsigned int lzo_uint; 109 | typedef int lzo_int; 110 | # define LZO_SIZEOF_LZO_INT LZO_SIZEOF_INT 111 | # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_INT 112 | # define LZO_UINT_MAX UINT_MAX 113 | # define LZO_INT_MAX INT_MAX 114 | # define LZO_INT_MIN INT_MIN 115 | # elif (ULONG_MAX >= LZO_0xffffffffL) 116 | typedef unsigned long lzo_uint; 117 | typedef long lzo_int; 118 | # define LZO_SIZEOF_LZO_INT LZO_SIZEOF_LONG 119 | # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG 120 | # define LZO_UINT_MAX ULONG_MAX 121 | # define LZO_INT_MAX LONG_MAX 122 | # define LZO_INT_MIN LONG_MIN 123 | # else 124 | # error "lzo_uint" 125 | # endif 126 | #endif 127 | 128 | /* The larger type of lzo_uint and lzo_uint32_t. */ 129 | #if (LZO_SIZEOF_LZO_INT >= 4) 130 | # define lzo_xint lzo_uint 131 | #else 132 | # define lzo_xint lzo_uint32_t 133 | #endif 134 | 135 | typedef int lzo_bool; 136 | 137 | /* sanity checks */ 138 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int) == LZO_SIZEOF_LZO_INT) 139 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_INT) 140 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) 141 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) 142 | 143 | #ifndef __LZO_MMODEL 144 | #define __LZO_MMODEL /*empty*/ 145 | #endif 146 | 147 | /* no typedef here because of const-pointer issues */ 148 | #define lzo_bytep unsigned char __LZO_MMODEL * 149 | #define lzo_charp char __LZO_MMODEL * 150 | #define lzo_voidp void __LZO_MMODEL * 151 | #define lzo_shortp short __LZO_MMODEL * 152 | #define lzo_ushortp unsigned short __LZO_MMODEL * 153 | #define lzo_intp lzo_int __LZO_MMODEL * 154 | #define lzo_uintp lzo_uint __LZO_MMODEL * 155 | #define lzo_xintp lzo_xint __LZO_MMODEL * 156 | #define lzo_voidpp lzo_voidp __LZO_MMODEL * 157 | #define lzo_bytepp lzo_bytep __LZO_MMODEL * 158 | 159 | #define lzo_int8_tp lzo_int8_t __LZO_MMODEL * 160 | #define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * 161 | #define lzo_int16_tp lzo_int16_t __LZO_MMODEL * 162 | #define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * 163 | #define lzo_int32_tp lzo_int32_t __LZO_MMODEL * 164 | #define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * 165 | #if defined(lzo_int64_t) 166 | #define lzo_int64_tp lzo_int64_t __LZO_MMODEL * 167 | #define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * 168 | #endif 169 | 170 | /* Older LZO versions used to support ancient systems and memory models 171 | * such as 16-bit MSDOS with __huge pointers or Cray PVP, but these 172 | * obsolete configurations are not supported any longer. 173 | */ 174 | #if defined(__LZO_MMODEL_HUGE) 175 | #error "__LZO_MMODEL_HUGE memory model is unsupported" 176 | #endif 177 | #if (LZO_MM_PVP) 178 | #error "LZO_MM_PVP memory model is unsupported" 179 | #endif 180 | #if (LZO_SIZEOF_INT < 4) 181 | #error "LZO_SIZEOF_INT < 4 is unsupported" 182 | #endif 183 | #if (__LZO_UINTPTR_T_IS_POINTER) 184 | #error "__LZO_UINTPTR_T_IS_POINTER is unsupported" 185 | #endif 186 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) 187 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) 188 | /* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should 189 | * work but have not received much testing lately, so be strict here. 190 | */ 191 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) 192 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) 193 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) 194 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) 195 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) 196 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) 197 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) 198 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) 199 | 200 | 201 | /*********************************************************************** 202 | // function types 203 | ************************************************************************/ 204 | 205 | /* name mangling */ 206 | #if !defined(__LZO_EXTERN_C) 207 | # ifdef __cplusplus 208 | # define __LZO_EXTERN_C extern "C" 209 | # else 210 | # define __LZO_EXTERN_C extern 211 | # endif 212 | #endif 213 | 214 | /* calling convention */ 215 | #if !defined(__LZO_CDECL) 216 | # define __LZO_CDECL __lzo_cdecl 217 | #endif 218 | 219 | /* DLL export information */ 220 | #if !defined(__LZO_EXPORT1) 221 | # define __LZO_EXPORT1 /*empty*/ 222 | #endif 223 | #if !defined(__LZO_EXPORT2) 224 | # define __LZO_EXPORT2 /*empty*/ 225 | #endif 226 | 227 | /* __cdecl calling convention for public C and assembly functions */ 228 | #if !defined(LZO_PUBLIC) 229 | # define LZO_PUBLIC(r) __LZO_EXPORT1 r __LZO_EXPORT2 __LZO_CDECL 230 | #endif 231 | #if !defined(LZO_EXTERN) 232 | # define LZO_EXTERN(r) __LZO_EXTERN_C LZO_PUBLIC(r) 233 | #endif 234 | #if !defined(LZO_PRIVATE) 235 | # define LZO_PRIVATE(r) static r __LZO_CDECL 236 | #endif 237 | 238 | /* function types */ 239 | typedef int 240 | (__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, 241 | lzo_bytep dst, lzo_uintp dst_len, 242 | lzo_voidp wrkmem ); 243 | 244 | typedef int 245 | (__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, 246 | lzo_bytep dst, lzo_uintp dst_len, 247 | lzo_voidp wrkmem ); 248 | 249 | typedef int 250 | (__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, 251 | lzo_bytep dst, lzo_uintp dst_len, 252 | lzo_voidp wrkmem ); 253 | 254 | typedef int 255 | (__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, 256 | lzo_bytep dst, lzo_uintp dst_len, 257 | lzo_voidp wrkmem, 258 | const lzo_bytep dict, lzo_uint dict_len ); 259 | 260 | typedef int 261 | (__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, 262 | lzo_bytep dst, lzo_uintp dst_len, 263 | lzo_voidp wrkmem, 264 | const lzo_bytep dict, lzo_uint dict_len ); 265 | 266 | 267 | /* Callback interface. Currently only the progress indicator ("nprogress") 268 | * is used, but this may change in a future release. */ 269 | 270 | struct lzo_callback_t; 271 | typedef struct lzo_callback_t lzo_callback_t; 272 | #define lzo_callback_p lzo_callback_t __LZO_MMODEL * 273 | 274 | /* malloc & free function types */ 275 | typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) 276 | (lzo_callback_p self, lzo_uint items, lzo_uint size); 277 | typedef void (__LZO_CDECL *lzo_free_func_t) 278 | (lzo_callback_p self, lzo_voidp ptr); 279 | 280 | /* a progress indicator callback function */ 281 | typedef void (__LZO_CDECL *lzo_progress_func_t) 282 | (lzo_callback_p, lzo_uint, lzo_uint, int); 283 | 284 | struct lzo_callback_t 285 | { 286 | /* custom allocators (set to 0 to disable) */ 287 | lzo_alloc_func_t nalloc; /* [not used right now] */ 288 | lzo_free_func_t nfree; /* [not used right now] */ 289 | 290 | /* a progress indicator callback function (set to 0 to disable) */ 291 | lzo_progress_func_t nprogress; 292 | 293 | /* INFO: the first parameter "self" of the nalloc/nfree/nprogress 294 | * callbacks points back to this struct, so you are free to store 295 | * some extra info in the following variables. */ 296 | lzo_voidp user1; 297 | lzo_xint user2; 298 | lzo_xint user3; 299 | }; 300 | 301 | 302 | /*********************************************************************** 303 | // error codes and prototypes 304 | ************************************************************************/ 305 | 306 | /* Error codes for the compression/decompression functions. Negative 307 | * values are errors, positive values will be used for special but 308 | * normal events. 309 | */ 310 | #define LZO_E_OK 0 311 | #define LZO_E_ERROR (-1) 312 | #define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */ 313 | #define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ 314 | #define LZO_E_INPUT_OVERRUN (-4) 315 | #define LZO_E_OUTPUT_OVERRUN (-5) 316 | #define LZO_E_LOOKBEHIND_OVERRUN (-6) 317 | #define LZO_E_EOF_NOT_FOUND (-7) 318 | #define LZO_E_INPUT_NOT_CONSUMED (-8) 319 | #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ 320 | #define LZO_E_INVALID_ARGUMENT (-10) 321 | #define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ 322 | #define LZO_E_OUTPUT_NOT_CONSUMED (-12) 323 | #define LZO_E_INTERNAL_ERROR (-99) 324 | 325 | 326 | #ifndef lzo_sizeof_dict_t 327 | # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) 328 | #endif 329 | 330 | /* lzo_init() should be the first function you call. 331 | * Check the return code ! 332 | * 333 | * lzo_init() is a macro to allow checking that the library and the 334 | * compiler's view of various types are consistent. 335 | */ 336 | #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ 337 | (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ 338 | (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ 339 | (int)sizeof(lzo_callback_t)) 340 | LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); 341 | 342 | /* version functions (useful for shared libraries) */ 343 | LZO_EXTERN(unsigned) lzo_version(void); 344 | LZO_EXTERN(const char *) lzo_version_string(void); 345 | LZO_EXTERN(const char *) lzo_version_date(void); 346 | LZO_EXTERN(const lzo_charp) _lzo_version_string(void); 347 | LZO_EXTERN(const lzo_charp) _lzo_version_date(void); 348 | 349 | /* string functions */ 350 | LZO_EXTERN(int) 351 | lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len); 352 | LZO_EXTERN(lzo_voidp) 353 | lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len); 354 | LZO_EXTERN(lzo_voidp) 355 | lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len); 356 | LZO_EXTERN(lzo_voidp) 357 | lzo_memset(lzo_voidp buf, int c, lzo_uint len); 358 | 359 | /* checksum functions */ 360 | LZO_EXTERN(lzo_uint32_t) 361 | lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); 362 | LZO_EXTERN(lzo_uint32_t) 363 | lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); 364 | LZO_EXTERN(const lzo_uint32_tp) 365 | lzo_get_crc32_table(void); 366 | 367 | /* misc. */ 368 | LZO_EXTERN(int) _lzo_config_check(void); 369 | typedef union { 370 | lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; 371 | void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; 372 | #if defined(lzo_int64_t) 373 | lzo_uint64_t a10; 374 | #endif 375 | } lzo_align_t; 376 | 377 | /* align a char pointer on a boundary that is a multiple of 'size' */ 378 | LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); 379 | #define LZO_PTR_ALIGN_UP(p,size) \ 380 | ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size))) 381 | 382 | 383 | /*********************************************************************** 384 | // deprecated macros - only for backward compatibility 385 | ************************************************************************/ 386 | 387 | /* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ 388 | #define lzo_byte unsigned char 389 | /* deprecated type names */ 390 | #define lzo_int32 lzo_int32_t 391 | #define lzo_uint32 lzo_uint32_t 392 | #define lzo_int32p lzo_int32_t __LZO_MMODEL * 393 | #define lzo_uint32p lzo_uint32_t __LZO_MMODEL * 394 | #define LZO_INT32_MAX LZO_INT32_C(2147483647) 395 | #define LZO_UINT32_MAX LZO_UINT32_C(4294967295) 396 | #if defined(lzo_int64_t) 397 | #define lzo_int64 lzo_int64_t 398 | #define lzo_uint64 lzo_uint64_t 399 | #define lzo_int64p lzo_int64_t __LZO_MMODEL * 400 | #define lzo_uint64p lzo_uint64_t __LZO_MMODEL * 401 | #define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) 402 | #define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) 403 | #endif 404 | /* deprecated types */ 405 | typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; 406 | typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; 407 | /* deprecated defines */ 408 | #if !defined(LZO_SIZEOF_LZO_UINT) 409 | # define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LZO_INT 410 | #endif 411 | 412 | #if defined(LZO_CFG_COMPAT) 413 | 414 | #define __LZOCONF_H 1 415 | 416 | #if defined(LZO_ARCH_I086) 417 | # define __LZO_i386 1 418 | #elif defined(LZO_ARCH_I386) 419 | # define __LZO_i386 1 420 | #endif 421 | 422 | #if defined(LZO_OS_DOS16) 423 | # define __LZO_DOS 1 424 | # define __LZO_DOS16 1 425 | #elif defined(LZO_OS_DOS32) 426 | # define __LZO_DOS 1 427 | #elif defined(LZO_OS_WIN16) 428 | # define __LZO_WIN 1 429 | # define __LZO_WIN16 1 430 | #elif defined(LZO_OS_WIN32) 431 | # define __LZO_WIN 1 432 | #endif 433 | 434 | #define __LZO_CMODEL /*empty*/ 435 | #define __LZO_DMODEL /*empty*/ 436 | #define __LZO_ENTRY __LZO_CDECL 437 | #define LZO_EXTERN_CDECL LZO_EXTERN 438 | #define LZO_ALIGN LZO_PTR_ALIGN_UP 439 | 440 | #define lzo_compress_asm_t lzo_compress_t 441 | #define lzo_decompress_asm_t lzo_decompress_t 442 | 443 | #endif /* LZO_CFG_COMPAT */ 444 | 445 | 446 | #ifdef __cplusplus 447 | } /* extern "C" */ 448 | #endif 449 | 450 | #endif /* already included */ 451 | 452 | 453 | /* vim:set ts=4 sw=4 et: */ 454 | -------------------------------------------------------------------------------- /src/lzo/minilzo/lzodefs.h: -------------------------------------------------------------------------------- 1 | /* lzodefs.h -- architecture, OS and compiler specific defines 2 | 3 | This file is part of the LZO real-time data compression library. 4 | 5 | Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer 6 | All Rights Reserved. 7 | 8 | The LZO library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of 11 | the License, or (at your option) any later version. 12 | 13 | The LZO library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with the LZO library; see the file COPYING. 20 | If not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | Markus F.X.J. Oberhumer 24 | 25 | http://www.oberhumer.com/opensource/lzo/ 26 | */ 27 | 28 | 29 | #ifndef __LZODEFS_H_INCLUDED 30 | #define __LZODEFS_H_INCLUDED 1 31 | 32 | #if defined(__CYGWIN32__) && !defined(__CYGWIN__) 33 | # define __CYGWIN__ __CYGWIN32__ 34 | #endif 35 | #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) 36 | # define _ALL_SOURCE 1 37 | #endif 38 | #if defined(__mips__) && defined(__R5900__) 39 | # if !defined(__LONG_MAX__) 40 | # define __LONG_MAX__ 9223372036854775807L 41 | # endif 42 | #endif 43 | #if !defined(LZO_CFG_NO_DISABLE_WUNDEF) 44 | #if defined(__ARMCC_VERSION) 45 | # pragma diag_suppress 193 46 | #elif defined(__clang__) && defined(__clang_minor__) 47 | # pragma clang diagnostic ignored "-Wundef" 48 | #elif defined(__INTEL_COMPILER) 49 | # pragma warning(disable: 193) 50 | #elif defined(__KEIL__) && defined(__C166__) 51 | # pragma warning disable = 322 52 | #elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) 53 | # if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) 54 | # pragma GCC diagnostic ignored "-Wundef" 55 | # endif 56 | #elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) 57 | # if ((_MSC_VER-0) >= 1300) 58 | # pragma warning(disable: 4668) 59 | # endif 60 | #endif 61 | #endif 62 | #if 0 && defined(__POCC__) && defined(_WIN32) 63 | # if (__POCC__ >= 400) 64 | # pragma warn(disable: 2216) 65 | # endif 66 | #endif 67 | #if 0 && defined(__WATCOMC__) 68 | # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) 69 | # pragma warning 203 9 70 | # endif 71 | #endif 72 | #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) 73 | # pragma option -h 74 | #endif 75 | #if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) 76 | #ifndef _CRT_NONSTDC_NO_DEPRECATE 77 | #define _CRT_NONSTDC_NO_DEPRECATE 1 78 | #endif 79 | #ifndef _CRT_NONSTDC_NO_WARNINGS 80 | #define _CRT_NONSTDC_NO_WARNINGS 1 81 | #endif 82 | #ifndef _CRT_SECURE_NO_DEPRECATE 83 | #define _CRT_SECURE_NO_DEPRECATE 1 84 | #endif 85 | #ifndef _CRT_SECURE_NO_WARNINGS 86 | #define _CRT_SECURE_NO_WARNINGS 1 87 | #endif 88 | #endif 89 | #if 0 90 | #define LZO_0xffffUL 0xfffful 91 | #define LZO_0xffffffffUL 0xfffffffful 92 | #else 93 | #define LZO_0xffffUL 65535ul 94 | #define LZO_0xffffffffUL 4294967295ul 95 | #endif 96 | #define LZO_0xffffL LZO_0xffffUL 97 | #define LZO_0xffffffffL LZO_0xffffffffUL 98 | #if (LZO_0xffffL == LZO_0xffffffffL) 99 | # error "your preprocessor is broken 1" 100 | #endif 101 | #if (16ul * 16384ul != 262144ul) 102 | # error "your preprocessor is broken 2" 103 | #endif 104 | #if 0 105 | #if (32767 >= 4294967295ul) 106 | # error "your preprocessor is broken 3" 107 | #endif 108 | #if (65535u >= 4294967295ul) 109 | # error "your preprocessor is broken 4" 110 | #endif 111 | #endif 112 | #if defined(__COUNTER__) 113 | # ifndef LZO_CFG_USE_COUNTER 114 | # define LZO_CFG_USE_COUNTER 1 115 | # endif 116 | #else 117 | # undef LZO_CFG_USE_COUNTER 118 | #endif 119 | #if (UINT_MAX == LZO_0xffffL) 120 | #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) 121 | # if !defined(MSDOS) 122 | # define MSDOS 1 123 | # endif 124 | # if !defined(_MSDOS) 125 | # define _MSDOS 1 126 | # endif 127 | #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) 128 | # if (__VERSION == 520) && (MB_LEN_MAX == 1) 129 | # if !defined(__AZTEC_C__) 130 | # define __AZTEC_C__ __VERSION 131 | # endif 132 | # if !defined(__DOS__) 133 | # define __DOS__ 1 134 | # endif 135 | # endif 136 | #endif 137 | #endif 138 | #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) 139 | # define ptrdiff_t long 140 | # define _PTRDIFF_T_DEFINED 1 141 | #endif 142 | #if (UINT_MAX == LZO_0xffffL) 143 | # undef __LZO_RENAME_A 144 | # undef __LZO_RENAME_B 145 | # if defined(__AZTEC_C__) && defined(__DOS__) 146 | # define __LZO_RENAME_A 1 147 | # elif defined(_MSC_VER) && defined(MSDOS) 148 | # if (_MSC_VER < 600) 149 | # define __LZO_RENAME_A 1 150 | # elif (_MSC_VER < 700) 151 | # define __LZO_RENAME_B 1 152 | # endif 153 | # elif defined(__TSC__) && defined(__OS2__) 154 | # define __LZO_RENAME_A 1 155 | # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) 156 | # define __LZO_RENAME_A 1 157 | # elif defined(__PACIFIC__) && defined(DOS) 158 | # if !defined(__far) 159 | # define __far far 160 | # endif 161 | # if !defined(__near) 162 | # define __near near 163 | # endif 164 | # endif 165 | # if defined(__LZO_RENAME_A) 166 | # if !defined(__cdecl) 167 | # define __cdecl cdecl 168 | # endif 169 | # if !defined(__far) 170 | # define __far far 171 | # endif 172 | # if !defined(__huge) 173 | # define __huge huge 174 | # endif 175 | # if !defined(__near) 176 | # define __near near 177 | # endif 178 | # if !defined(__pascal) 179 | # define __pascal pascal 180 | # endif 181 | # if !defined(__huge) 182 | # define __huge huge 183 | # endif 184 | # elif defined(__LZO_RENAME_B) 185 | # if !defined(__cdecl) 186 | # define __cdecl _cdecl 187 | # endif 188 | # if !defined(__far) 189 | # define __far _far 190 | # endif 191 | # if !defined(__huge) 192 | # define __huge _huge 193 | # endif 194 | # if !defined(__near) 195 | # define __near _near 196 | # endif 197 | # if !defined(__pascal) 198 | # define __pascal _pascal 199 | # endif 200 | # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) 201 | # if !defined(__cdecl) 202 | # define __cdecl cdecl 203 | # endif 204 | # if !defined(__pascal) 205 | # define __pascal pascal 206 | # endif 207 | # endif 208 | # undef __LZO_RENAME_A 209 | # undef __LZO_RENAME_B 210 | #endif 211 | #if (UINT_MAX == LZO_0xffffL) 212 | #if defined(__AZTEC_C__) && defined(__DOS__) 213 | # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 214 | #elif defined(_MSC_VER) && defined(MSDOS) 215 | # if (_MSC_VER < 600) 216 | # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 217 | # endif 218 | # if (_MSC_VER < 700) 219 | # define LZO_BROKEN_INTEGRAL_PROMOTION 1 220 | # define LZO_BROKEN_SIZEOF 1 221 | # endif 222 | #elif defined(__PACIFIC__) && defined(DOS) 223 | # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 224 | #elif defined(__TURBOC__) && defined(__MSDOS__) 225 | # if (__TURBOC__ < 0x0150) 226 | # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 227 | # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 228 | # define LZO_BROKEN_INTEGRAL_PROMOTION 1 229 | # endif 230 | # if (__TURBOC__ < 0x0200) 231 | # define LZO_BROKEN_SIZEOF 1 232 | # endif 233 | # if (__TURBOC__ < 0x0400) && defined(__cplusplus) 234 | # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 235 | # endif 236 | #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) 237 | # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 238 | # define LZO_BROKEN_SIZEOF 1 239 | #endif 240 | #endif 241 | #if defined(__WATCOMC__) && (__WATCOMC__ < 900) 242 | # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 243 | #endif 244 | #if defined(_CRAY) && defined(_CRAY1) 245 | # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 246 | #endif 247 | #define LZO_PP_STRINGIZE(x) #x 248 | #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) 249 | #define LZO_PP_CONCAT0() /*empty*/ 250 | #define LZO_PP_CONCAT1(a) a 251 | #define LZO_PP_CONCAT2(a,b) a ## b 252 | #define LZO_PP_CONCAT3(a,b,c) a ## b ## c 253 | #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d 254 | #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e 255 | #define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f 256 | #define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g 257 | #define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() 258 | #define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) 259 | #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) 260 | #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) 261 | #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) 262 | #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) 263 | #define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) 264 | #define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) 265 | #define LZO_PP_EMPTY /*empty*/ 266 | #define LZO_PP_EMPTY0() /*empty*/ 267 | #define LZO_PP_EMPTY1(a) /*empty*/ 268 | #define LZO_PP_EMPTY2(a,b) /*empty*/ 269 | #define LZO_PP_EMPTY3(a,b,c) /*empty*/ 270 | #define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ 271 | #define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ 272 | #define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ 273 | #define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ 274 | #if 1 275 | #define LZO_CPP_STRINGIZE(x) #x 276 | #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) 277 | #define LZO_CPP_CONCAT2(a,b) a ## b 278 | #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c 279 | #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d 280 | #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e 281 | #define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f 282 | #define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g 283 | #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) 284 | #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) 285 | #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) 286 | #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) 287 | #define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) 288 | #define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) 289 | #endif 290 | #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) 291 | #if 1 && defined(__cplusplus) 292 | # if !defined(__STDC_CONSTANT_MACROS) 293 | # define __STDC_CONSTANT_MACROS 1 294 | # endif 295 | # if !defined(__STDC_LIMIT_MACROS) 296 | # define __STDC_LIMIT_MACROS 1 297 | # endif 298 | #endif 299 | #if defined(__cplusplus) 300 | # define LZO_EXTERN_C extern "C" 301 | # define LZO_EXTERN_C_BEGIN extern "C" { 302 | # define LZO_EXTERN_C_END } 303 | #else 304 | # define LZO_EXTERN_C extern 305 | # define LZO_EXTERN_C_BEGIN /*empty*/ 306 | # define LZO_EXTERN_C_END /*empty*/ 307 | #endif 308 | #if !defined(__LZO_OS_OVERRIDE) 309 | #if (LZO_OS_FREESTANDING) 310 | # define LZO_INFO_OS "freestanding" 311 | #elif (LZO_OS_EMBEDDED) 312 | # define LZO_INFO_OS "embedded" 313 | #elif 1 && defined(__IAR_SYSTEMS_ICC__) 314 | # define LZO_OS_EMBEDDED 1 315 | # define LZO_INFO_OS "embedded" 316 | #elif defined(__CYGWIN__) && defined(__GNUC__) 317 | # define LZO_OS_CYGWIN 1 318 | # define LZO_INFO_OS "cygwin" 319 | #elif defined(__EMX__) && defined(__GNUC__) 320 | # define LZO_OS_EMX 1 321 | # define LZO_INFO_OS "emx" 322 | #elif defined(__BEOS__) 323 | # define LZO_OS_BEOS 1 324 | # define LZO_INFO_OS "beos" 325 | #elif defined(__Lynx__) 326 | # define LZO_OS_LYNXOS 1 327 | # define LZO_INFO_OS "lynxos" 328 | #elif defined(__OS400__) 329 | # define LZO_OS_OS400 1 330 | # define LZO_INFO_OS "os400" 331 | #elif defined(__QNX__) 332 | # define LZO_OS_QNX 1 333 | # define LZO_INFO_OS "qnx" 334 | #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) 335 | # define LZO_OS_DOS32 1 336 | # define LZO_INFO_OS "dos32" 337 | #elif defined(__BORLANDC__) && defined(__DPMI16__) 338 | # define LZO_OS_DOS16 1 339 | # define LZO_INFO_OS "dos16" 340 | #elif defined(__ZTC__) && defined(DOS386) 341 | # define LZO_OS_DOS32 1 342 | # define LZO_INFO_OS "dos32" 343 | #elif defined(__OS2__) || defined(__OS2V2__) 344 | # if (UINT_MAX == LZO_0xffffL) 345 | # define LZO_OS_OS216 1 346 | # define LZO_INFO_OS "os216" 347 | # elif (UINT_MAX == LZO_0xffffffffL) 348 | # define LZO_OS_OS2 1 349 | # define LZO_INFO_OS "os2" 350 | # else 351 | # error "check your limits.h header" 352 | # endif 353 | #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) 354 | # define LZO_OS_WIN64 1 355 | # define LZO_INFO_OS "win64" 356 | #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) 357 | # define LZO_OS_WIN32 1 358 | # define LZO_INFO_OS "win32" 359 | #elif defined(__MWERKS__) && defined(__INTEL__) 360 | # define LZO_OS_WIN32 1 361 | # define LZO_INFO_OS "win32" 362 | #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) 363 | # if (UINT_MAX == LZO_0xffffL) 364 | # define LZO_OS_WIN16 1 365 | # define LZO_INFO_OS "win16" 366 | # elif (UINT_MAX == LZO_0xffffffffL) 367 | # define LZO_OS_WIN32 1 368 | # define LZO_INFO_OS "win32" 369 | # else 370 | # error "check your limits.h header" 371 | # endif 372 | #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) 373 | # if (UINT_MAX == LZO_0xffffL) 374 | # define LZO_OS_DOS16 1 375 | # define LZO_INFO_OS "dos16" 376 | # elif (UINT_MAX == LZO_0xffffffffL) 377 | # define LZO_OS_DOS32 1 378 | # define LZO_INFO_OS "dos32" 379 | # else 380 | # error "check your limits.h header" 381 | # endif 382 | #elif defined(__WATCOMC__) 383 | # if defined(__NT__) && (UINT_MAX == LZO_0xffffL) 384 | # define LZO_OS_DOS16 1 385 | # define LZO_INFO_OS "dos16" 386 | # elif defined(__NT__) && (__WATCOMC__ < 1100) 387 | # define LZO_OS_WIN32 1 388 | # define LZO_INFO_OS "win32" 389 | # elif defined(__linux__) || defined(__LINUX__) 390 | # define LZO_OS_POSIX 1 391 | # define LZO_INFO_OS "posix" 392 | # else 393 | # error "please specify a target using the -bt compiler option" 394 | # endif 395 | #elif defined(__palmos__) 396 | # define LZO_OS_PALMOS 1 397 | # define LZO_INFO_OS "palmos" 398 | #elif defined(__TOS__) || defined(__atarist__) 399 | # define LZO_OS_TOS 1 400 | # define LZO_INFO_OS "tos" 401 | #elif defined(macintosh) && !defined(__arm__) && !defined(__i386__) && !defined(__ppc__) && !defined(__x64_64__) 402 | # define LZO_OS_MACCLASSIC 1 403 | # define LZO_INFO_OS "macclassic" 404 | #elif defined(__VMS) 405 | # define LZO_OS_VMS 1 406 | # define LZO_INFO_OS "vms" 407 | #elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) 408 | # define LZO_OS_CONSOLE 1 409 | # define LZO_OS_CONSOLE_PS2 1 410 | # define LZO_INFO_OS "console" 411 | # define LZO_INFO_OS_CONSOLE "ps2" 412 | #elif defined(__mips__) && defined(__psp__) 413 | # define LZO_OS_CONSOLE 1 414 | # define LZO_OS_CONSOLE_PSP 1 415 | # define LZO_INFO_OS "console" 416 | # define LZO_INFO_OS_CONSOLE "psp" 417 | #else 418 | # define LZO_OS_POSIX 1 419 | # define LZO_INFO_OS "posix" 420 | #endif 421 | #if (LZO_OS_POSIX) 422 | # if defined(_AIX) || defined(__AIX__) || defined(__aix__) 423 | # define LZO_OS_POSIX_AIX 1 424 | # define LZO_INFO_OS_POSIX "aix" 425 | # elif defined(__FreeBSD__) 426 | # define LZO_OS_POSIX_FREEBSD 1 427 | # define LZO_INFO_OS_POSIX "freebsd" 428 | # elif defined(__hpux__) || defined(__hpux) 429 | # define LZO_OS_POSIX_HPUX 1 430 | # define LZO_INFO_OS_POSIX "hpux" 431 | # elif defined(__INTERIX) 432 | # define LZO_OS_POSIX_INTERIX 1 433 | # define LZO_INFO_OS_POSIX "interix" 434 | # elif defined(__IRIX__) || defined(__irix__) 435 | # define LZO_OS_POSIX_IRIX 1 436 | # define LZO_INFO_OS_POSIX "irix" 437 | # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) 438 | # define LZO_OS_POSIX_LINUX 1 439 | # define LZO_INFO_OS_POSIX "linux" 440 | # elif defined(__APPLE__) && defined(__MACH__) 441 | # if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) 442 | # define LZO_OS_POSIX_DARWIN 1040 443 | # define LZO_INFO_OS_POSIX "darwin_iphone" 444 | # elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) 445 | # define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 446 | # define LZO_INFO_OS_POSIX "darwin" 447 | # else 448 | # define LZO_OS_POSIX_DARWIN 1 449 | # define LZO_INFO_OS_POSIX "darwin" 450 | # endif 451 | # define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN 452 | # elif defined(__minix__) || defined(__minix) 453 | # define LZO_OS_POSIX_MINIX 1 454 | # define LZO_INFO_OS_POSIX "minix" 455 | # elif defined(__NetBSD__) 456 | # define LZO_OS_POSIX_NETBSD 1 457 | # define LZO_INFO_OS_POSIX "netbsd" 458 | # elif defined(__OpenBSD__) 459 | # define LZO_OS_POSIX_OPENBSD 1 460 | # define LZO_INFO_OS_POSIX "openbsd" 461 | # elif defined(__osf__) 462 | # define LZO_OS_POSIX_OSF 1 463 | # define LZO_INFO_OS_POSIX "osf" 464 | # elif defined(__solaris__) || defined(__sun) 465 | # if defined(__SVR4) || defined(__svr4__) 466 | # define LZO_OS_POSIX_SOLARIS 1 467 | # define LZO_INFO_OS_POSIX "solaris" 468 | # else 469 | # define LZO_OS_POSIX_SUNOS 1 470 | # define LZO_INFO_OS_POSIX "sunos" 471 | # endif 472 | # elif defined(__ultrix__) || defined(__ultrix) 473 | # define LZO_OS_POSIX_ULTRIX 1 474 | # define LZO_INFO_OS_POSIX "ultrix" 475 | # elif defined(_UNICOS) 476 | # define LZO_OS_POSIX_UNICOS 1 477 | # define LZO_INFO_OS_POSIX "unicos" 478 | # else 479 | # define LZO_OS_POSIX_UNKNOWN 1 480 | # define LZO_INFO_OS_POSIX "unknown" 481 | # endif 482 | #endif 483 | #endif 484 | #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 485 | # if (UINT_MAX != LZO_0xffffL) 486 | # error "unexpected configuration - check your compiler defines" 487 | # endif 488 | # if (ULONG_MAX != LZO_0xffffffffL) 489 | # error "unexpected configuration - check your compiler defines" 490 | # endif 491 | #endif 492 | #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) 493 | # if (UINT_MAX != LZO_0xffffffffL) 494 | # error "unexpected configuration - check your compiler defines" 495 | # endif 496 | # if (ULONG_MAX != LZO_0xffffffffL) 497 | # error "unexpected configuration - check your compiler defines" 498 | # endif 499 | #endif 500 | #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) 501 | # define LZO_CC_CILLY 1 502 | # define LZO_INFO_CC "Cilly" 503 | # if defined(__CILLY__) 504 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) 505 | # else 506 | # define LZO_INFO_CCVER "unknown" 507 | # endif 508 | #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) 509 | # define LZO_CC_SDCC 1 510 | # define LZO_INFO_CC "sdcc" 511 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) 512 | #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) 513 | # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) 514 | # define LZO_INFO_CC "Pathscale C" 515 | # define LZO_INFO_CCVER __PATHSCALE__ 516 | # if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) 517 | # define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 518 | # endif 519 | #elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) 520 | # define LZO_CC_INTELC __INTEL_COMPILER 521 | # define LZO_INFO_CC "Intel C" 522 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) 523 | # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) 524 | # define LZO_CC_INTELC_MSC _MSC_VER 525 | # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) 526 | # define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 527 | # endif 528 | #elif defined(__POCC__) && defined(_WIN32) 529 | # define LZO_CC_PELLESC 1 530 | # define LZO_INFO_CC "Pelles C" 531 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) 532 | #elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) 533 | # if defined(__GNUC_PATCHLEVEL__) 534 | # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 535 | # else 536 | # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) 537 | # endif 538 | # define LZO_CC_ARMCC __ARMCC_VERSION 539 | # define LZO_INFO_CC "ARM C Compiler" 540 | # define LZO_INFO_CCVER __VERSION__ 541 | #elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) 542 | # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) 543 | # define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) 544 | # else 545 | # define LZO_CC_CLANG 0x010000L 546 | # endif 547 | # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) 548 | # define LZO_CC_CLANG_MSC _MSC_VER 549 | # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) 550 | # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 551 | # endif 552 | # define LZO_INFO_CC "clang" 553 | # define LZO_INFO_CCVER __VERSION__ 554 | #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) 555 | # if defined(__GNUC_PATCHLEVEL__) 556 | # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 557 | # else 558 | # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) 559 | # endif 560 | # define LZO_CC_LLVM LZO_CC_LLVM_GNUC 561 | # define LZO_INFO_CC "llvm-gcc" 562 | # define LZO_INFO_CCVER __VERSION__ 563 | #elif defined(__ACK__) && defined(_ACK) 564 | # define LZO_CC_ACK 1 565 | # define LZO_INFO_CC "Amsterdam Compiler Kit C" 566 | # define LZO_INFO_CCVER "unknown" 567 | #elif defined(__ARMCC_VERSION) && !defined(__GNUC__) 568 | # define LZO_CC_ARMCC __ARMCC_VERSION 569 | # define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION 570 | # define LZO_INFO_CC "ARM C Compiler" 571 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) 572 | #elif defined(__AZTEC_C__) 573 | # define LZO_CC_AZTECC 1 574 | # define LZO_INFO_CC "Aztec C" 575 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) 576 | #elif defined(__CODEGEARC__) 577 | # define LZO_CC_CODEGEARC 1 578 | # define LZO_INFO_CC "CodeGear C" 579 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__) 580 | #elif defined(__BORLANDC__) 581 | # define LZO_CC_BORLANDC 1 582 | # define LZO_INFO_CC "Borland C" 583 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) 584 | #elif defined(_CRAYC) && defined(_RELEASE) 585 | # define LZO_CC_CRAYC 1 586 | # define LZO_INFO_CC "Cray C" 587 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) 588 | #elif defined(__DMC__) && defined(__SC__) 589 | # define LZO_CC_DMC 1 590 | # define LZO_INFO_CC "Digital Mars C" 591 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) 592 | #elif defined(__DECC) 593 | # define LZO_CC_DECC 1 594 | # define LZO_INFO_CC "DEC C" 595 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) 596 | #elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) 597 | # define LZO_CC_GHS 1 598 | # define LZO_INFO_CC "Green Hills C" 599 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) 600 | # if defined(_MSC_VER) && ((_MSC_VER-0) > 0) 601 | # define LZO_CC_GHS_MSC _MSC_VER 602 | # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) 603 | # define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 604 | # endif 605 | #elif defined(__HIGHC__) 606 | # define LZO_CC_HIGHC 1 607 | # define LZO_INFO_CC "MetaWare High C" 608 | # define LZO_INFO_CCVER "unknown" 609 | #elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) 610 | # define LZO_CC_HPACC __HP_aCC 611 | # define LZO_INFO_CC "HP aCC" 612 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) 613 | #elif defined(__IAR_SYSTEMS_ICC__) 614 | # define LZO_CC_IARC 1 615 | # define LZO_INFO_CC "IAR C" 616 | # if defined(__VER__) 617 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) 618 | # else 619 | # define LZO_INFO_CCVER "unknown" 620 | # endif 621 | #elif defined(__IBMC__) && ((__IBMC__-0) > 0) 622 | # define LZO_CC_IBMC __IBMC__ 623 | # define LZO_INFO_CC "IBM C" 624 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) 625 | #elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) 626 | # define LZO_CC_IBMC __IBMCPP__ 627 | # define LZO_INFO_CC "IBM C" 628 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) 629 | #elif defined(__KEIL__) && defined(__C166__) 630 | # define LZO_CC_KEILC 1 631 | # define LZO_INFO_CC "Keil C" 632 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) 633 | #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) 634 | # define LZO_CC_LCCWIN32 1 635 | # define LZO_INFO_CC "lcc-win32" 636 | # define LZO_INFO_CCVER "unknown" 637 | #elif defined(__LCC__) 638 | # define LZO_CC_LCC 1 639 | # define LZO_INFO_CC "lcc" 640 | # if defined(__LCC_VERSION__) 641 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) 642 | # else 643 | # define LZO_INFO_CCVER "unknown" 644 | # endif 645 | #elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) 646 | # define LZO_CC_MWERKS __MWERKS__ 647 | # define LZO_INFO_CC "Metrowerks C" 648 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) 649 | #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) 650 | # define LZO_CC_NDPC 1 651 | # define LZO_INFO_CC "Microway NDP C" 652 | # define LZO_INFO_CCVER "unknown" 653 | #elif defined(__PACIFIC__) 654 | # define LZO_CC_PACIFICC 1 655 | # define LZO_INFO_CC "Pacific C" 656 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) 657 | #elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) 658 | # if defined(__PGIC_PATCHLEVEL__) 659 | # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) 660 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) 661 | # else 662 | # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) 663 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" 664 | # endif 665 | # define LZO_INFO_CC "Portland Group PGI C" 666 | #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) 667 | # define LZO_CC_PGI 1 668 | # define LZO_INFO_CC "Portland Group PGI C" 669 | # define LZO_INFO_CCVER "unknown" 670 | #elif defined(__PUREC__) && defined(__TOS__) 671 | # define LZO_CC_PUREC 1 672 | # define LZO_INFO_CC "Pure C" 673 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) 674 | #elif defined(__SC__) && defined(__ZTC__) 675 | # define LZO_CC_SYMANTECC 1 676 | # define LZO_INFO_CC "Symantec C" 677 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) 678 | #elif defined(__SUNPRO_C) 679 | # define LZO_INFO_CC "SunPro C" 680 | # if ((__SUNPRO_C-0) > 0) 681 | # define LZO_CC_SUNPROC __SUNPRO_C 682 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) 683 | # else 684 | # define LZO_CC_SUNPROC 1 685 | # define LZO_INFO_CCVER "unknown" 686 | # endif 687 | #elif defined(__SUNPRO_CC) 688 | # define LZO_INFO_CC "SunPro C" 689 | # if ((__SUNPRO_CC-0) > 0) 690 | # define LZO_CC_SUNPROC __SUNPRO_CC 691 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) 692 | # else 693 | # define LZO_CC_SUNPROC 1 694 | # define LZO_INFO_CCVER "unknown" 695 | # endif 696 | #elif defined(__TINYC__) 697 | # define LZO_CC_TINYC 1 698 | # define LZO_INFO_CC "Tiny C" 699 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) 700 | #elif defined(__TSC__) 701 | # define LZO_CC_TOPSPEEDC 1 702 | # define LZO_INFO_CC "TopSpeed C" 703 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) 704 | #elif defined(__WATCOMC__) 705 | # define LZO_CC_WATCOMC 1 706 | # define LZO_INFO_CC "Watcom C" 707 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) 708 | #elif defined(__TURBOC__) 709 | # define LZO_CC_TURBOC 1 710 | # define LZO_INFO_CC "Turbo C" 711 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) 712 | #elif defined(__ZTC__) 713 | # define LZO_CC_ZORTECHC 1 714 | # define LZO_INFO_CC "Zortech C" 715 | # if ((__ZTC__-0) == 0x310) 716 | # define LZO_INFO_CCVER "0x310" 717 | # else 718 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) 719 | # endif 720 | #elif defined(__GNUC__) && defined(__VERSION__) 721 | # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 722 | # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) 723 | # elif defined(__GNUC_MINOR__) 724 | # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) 725 | # else 726 | # define LZO_CC_GNUC (__GNUC__ * 0x10000L) 727 | # endif 728 | # define LZO_INFO_CC "gcc" 729 | # define LZO_INFO_CCVER __VERSION__ 730 | #elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) 731 | # define LZO_CC_MSC _MSC_VER 732 | # define LZO_INFO_CC "Microsoft C" 733 | # if defined(_MSC_FULL_VER) 734 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) 735 | # else 736 | # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) 737 | # endif 738 | #else 739 | # define LZO_CC_UNKNOWN 1 740 | # define LZO_INFO_CC "unknown" 741 | # define LZO_INFO_CCVER "unknown" 742 | #endif 743 | #if (LZO_CC_GNUC) && defined(__OPEN64__) 744 | # if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) 745 | # define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) 746 | # define LZO_CC_OPEN64_GNUC LZO_CC_GNUC 747 | # endif 748 | #endif 749 | #if (LZO_CC_GNUC) && defined(__PCC__) 750 | # if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) 751 | # define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) 752 | # define LZO_CC_PCC_GNUC LZO_CC_GNUC 753 | # endif 754 | #endif 755 | #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) 756 | # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" 757 | #endif 758 | #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY) 759 | # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) 760 | # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) 761 | # define LZO_ARCH_CRAY_MPP 1 762 | # elif defined(_CRAY1) 763 | # define LZO_ARCH_CRAY_PVP 1 764 | # endif 765 | # endif 766 | #endif 767 | #if !defined(__LZO_ARCH_OVERRIDE) 768 | #if (LZO_ARCH_GENERIC) 769 | # define LZO_INFO_ARCH "generic" 770 | #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 771 | # define LZO_ARCH_I086 1 772 | # define LZO_INFO_ARCH "i086" 773 | #elif defined(__aarch64__) 774 | # define LZO_ARCH_ARM64 1 775 | # define LZO_INFO_ARCH "arm64" 776 | #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) 777 | # define LZO_ARCH_ALPHA 1 778 | # define LZO_INFO_ARCH "alpha" 779 | #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) 780 | # define LZO_ARCH_ALPHA 1 781 | # define LZO_INFO_ARCH "alpha" 782 | #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) 783 | # define LZO_ARCH_AMD64 1 784 | # define LZO_INFO_ARCH "amd64" 785 | #elif defined(__arm__) || defined(_M_ARM) 786 | # define LZO_ARCH_ARM 1 787 | # define LZO_INFO_ARCH "arm" 788 | #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) 789 | # define LZO_ARCH_ARM 1 790 | # define LZO_INFO_ARCH "arm" 791 | #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) 792 | # define LZO_ARCH_AVR 1 793 | # define LZO_INFO_ARCH "avr" 794 | #elif defined(__avr32__) || defined(__AVR32__) 795 | # define LZO_ARCH_AVR32 1 796 | # define LZO_INFO_ARCH "avr32" 797 | #elif defined(__bfin__) 798 | # define LZO_ARCH_BLACKFIN 1 799 | # define LZO_INFO_ARCH "blackfin" 800 | #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) 801 | # define LZO_ARCH_C166 1 802 | # define LZO_INFO_ARCH "c166" 803 | #elif defined(__cris__) 804 | # define LZO_ARCH_CRIS 1 805 | # define LZO_INFO_ARCH "cris" 806 | #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) 807 | # define LZO_ARCH_EZ80 1 808 | # define LZO_INFO_ARCH "ez80" 809 | #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) 810 | # define LZO_ARCH_H8300 1 811 | # define LZO_INFO_ARCH "h8300" 812 | #elif defined(__hppa__) || defined(__hppa) 813 | # define LZO_ARCH_HPPA 1 814 | # define LZO_INFO_ARCH "hppa" 815 | #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) 816 | # define LZO_ARCH_I386 1 817 | # define LZO_ARCH_IA32 1 818 | # define LZO_INFO_ARCH "i386" 819 | #elif (LZO_CC_ZORTECHC && defined(__I86__)) 820 | # define LZO_ARCH_I386 1 821 | # define LZO_ARCH_IA32 1 822 | # define LZO_INFO_ARCH "i386" 823 | #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) 824 | # define LZO_ARCH_I386 1 825 | # define LZO_ARCH_IA32 1 826 | # define LZO_INFO_ARCH "i386" 827 | #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) 828 | # define LZO_ARCH_IA64 1 829 | # define LZO_INFO_ARCH "ia64" 830 | #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) 831 | # define LZO_ARCH_M16C 1 832 | # define LZO_INFO_ARCH "m16c" 833 | #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) 834 | # define LZO_ARCH_M16C 1 835 | # define LZO_INFO_ARCH "m16c" 836 | #elif defined(__m32r__) 837 | # define LZO_ARCH_M32R 1 838 | # define LZO_INFO_ARCH "m32r" 839 | #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) 840 | # define LZO_ARCH_M68K 1 841 | # define LZO_INFO_ARCH "m68k" 842 | #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) 843 | # define LZO_ARCH_MCS251 1 844 | # define LZO_INFO_ARCH "mcs251" 845 | #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) 846 | # define LZO_ARCH_MCS51 1 847 | # define LZO_INFO_ARCH "mcs51" 848 | #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) 849 | # define LZO_ARCH_MCS51 1 850 | # define LZO_INFO_ARCH "mcs51" 851 | #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) 852 | # define LZO_ARCH_MIPS 1 853 | # define LZO_INFO_ARCH "mips" 854 | #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) 855 | # define LZO_ARCH_MSP430 1 856 | # define LZO_INFO_ARCH "msp430" 857 | #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) 858 | # define LZO_ARCH_MSP430 1 859 | # define LZO_INFO_ARCH "msp430" 860 | #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) 861 | # define LZO_ARCH_POWERPC 1 862 | # define LZO_INFO_ARCH "powerpc" 863 | #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) 864 | # define LZO_ARCH_S390 1 865 | # define LZO_INFO_ARCH "s390" 866 | #elif defined(__sh__) || defined(_M_SH) 867 | # define LZO_ARCH_SH 1 868 | # define LZO_INFO_ARCH "sh" 869 | #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) 870 | # define LZO_ARCH_SPARC 1 871 | # define LZO_INFO_ARCH "sparc" 872 | #elif defined(__SPU__) 873 | # define LZO_ARCH_SPU 1 874 | # define LZO_INFO_ARCH "spu" 875 | #elif (UINT_MAX == LZO_0xffffL) && defined(__z80) 876 | # define LZO_ARCH_Z80 1 877 | # define LZO_INFO_ARCH "z80" 878 | #elif (LZO_ARCH_CRAY_PVP) 879 | # if defined(_CRAYSV1) 880 | # define LZO_ARCH_CRAY_SV1 1 881 | # define LZO_INFO_ARCH "cray_sv1" 882 | # elif (_ADDR64) 883 | # define LZO_ARCH_CRAY_T90 1 884 | # define LZO_INFO_ARCH "cray_t90" 885 | # elif (_ADDR32) 886 | # define LZO_ARCH_CRAY_YMP 1 887 | # define LZO_INFO_ARCH "cray_ymp" 888 | # else 889 | # define LZO_ARCH_CRAY_XMP 1 890 | # define LZO_INFO_ARCH "cray_xmp" 891 | # endif 892 | #else 893 | # define LZO_ARCH_UNKNOWN 1 894 | # define LZO_INFO_ARCH "unknown" 895 | #endif 896 | #endif 897 | #if !defined(LZO_ARCH_ARM_THUMB2) 898 | #if (LZO_ARCH_ARM) 899 | # if defined(__ARM_ARCH_ISA_THUMB) 900 | # if ((__ARM_ARCH_ISA_THUMB)+0 >= 2) 901 | # define LZO_ARCH_ARM_THUMB2 1 902 | # endif 903 | # elif 1 && defined(__thumb2__) 904 | # define LZO_ARCH_ARM_THUMB2 1 905 | # elif 1 && defined(__TARGET_ARCH_THUMB) && ((__TARGET_ARCH_THUMB)+0 >= 4) 906 | # define LZO_ARCH_ARM_THUMB2 1 907 | # endif 908 | #endif 909 | #endif 910 | #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) 911 | # error "FIXME - missing define for CPU architecture" 912 | #endif 913 | #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) 914 | # error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" 915 | #endif 916 | #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) 917 | # error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" 918 | #endif 919 | #if (LZO_OS_OS216 || LZO_OS_WIN16) 920 | # define LZO_ARCH_I086PM 1 921 | #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) 922 | # define LZO_ARCH_I086PM 1 923 | #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) 924 | # define LZO_ARCH_I086PM 1 925 | #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) 926 | # define LZO_ARCH_I086PM 1 927 | #endif 928 | #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) 929 | # define LZO_ARCH_X64 1 930 | #elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) 931 | # define LZO_ARCH_AMD64 1 932 | #endif 933 | #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) 934 | # define LZO_ARCH_AARCH64 1 935 | #elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) 936 | # define LZO_ARCH_ARM64 1 937 | #endif 938 | #if (LZO_ARCH_I386 && !LZO_ARCH_X86) 939 | # define LZO_ARCH_X86 1 940 | #elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) 941 | # define LZO_ARCH_I386 1 942 | #endif 943 | #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) 944 | # error "unexpected configuration - check your compiler defines" 945 | #endif 946 | #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) 947 | # error "unexpected configuration - check your compiler defines" 948 | #endif 949 | #if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) 950 | # error "unexpected configuration - check your compiler defines" 951 | #endif 952 | #if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM) 953 | # error "unexpected configuration - check your compiler defines" 954 | #endif 955 | #if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM) 956 | # error "unexpected configuration - check your compiler defines" 957 | #endif 958 | #if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) 959 | # error "unexpected configuration - check your compiler defines" 960 | #endif 961 | #if (LZO_ARCH_I086PM && !LZO_ARCH_I086) 962 | # error "unexpected configuration - check your compiler defines" 963 | #endif 964 | #if (LZO_ARCH_I086) 965 | # if (UINT_MAX != LZO_0xffffL) 966 | # error "unexpected configuration - check your compiler defines" 967 | # endif 968 | # if (ULONG_MAX != LZO_0xffffffffL) 969 | # error "unexpected configuration - check your compiler defines" 970 | # endif 971 | #endif 972 | #if (LZO_ARCH_I386) 973 | # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) 974 | # error "unexpected configuration - check your compiler defines" 975 | # endif 976 | # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) 977 | # error "unexpected configuration - check your compiler defines" 978 | # endif 979 | # if (ULONG_MAX != LZO_0xffffffffL) 980 | # error "unexpected configuration - check your compiler defines" 981 | # endif 982 | #endif 983 | #if (LZO_ARCH_AMD64 || LZO_ARCH_I386) 984 | # if !defined(LZO_TARGET_FEATURE_SSE2) 985 | # if defined(__SSE2__) 986 | # define LZO_TARGET_FEATURE_SSE2 1 987 | # elif defined(_MSC_VER) && (defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) 988 | # define LZO_TARGET_FEATURE_SSE2 1 989 | # elif (LZO_CC_INTELC_MSC || LZO_CC_MSC) && defined(_M_AMD64) 990 | # define LZO_TARGET_FEATURE_SSE2 1 991 | # endif 992 | # endif 993 | # if !defined(LZO_TARGET_FEATURE_SSSE3) 994 | # if (LZO_TARGET_FEATURE_SSE2) 995 | # if defined(__SSSE3__) 996 | # define LZO_TARGET_FEATURE_SSSE3 1 997 | # elif defined(_MSC_VER) && defined(__AVX__) 998 | # define LZO_TARGET_FEATURE_SSSE3 1 999 | # endif 1000 | # endif 1001 | # endif 1002 | # if !defined(LZO_TARGET_FEATURE_SSE4_2) 1003 | # if (LZO_TARGET_FEATURE_SSSE3) 1004 | # if defined(__SSE4_2__) 1005 | # define LZO_TARGET_FEATURE_SSE4_2 1 1006 | # endif 1007 | # endif 1008 | # endif 1009 | # if !defined(LZO_TARGET_FEATURE_AVX) 1010 | # if (LZO_TARGET_FEATURE_SSSE3) 1011 | # if defined(__AVX__) 1012 | # define LZO_TARGET_FEATURE_AVX 1 1013 | # endif 1014 | # endif 1015 | # endif 1016 | # if !defined(LZO_TARGET_FEATURE_AVX2) 1017 | # if (LZO_TARGET_FEATURE_AVX) 1018 | # if defined(__AVX2__) 1019 | # define LZO_TARGET_FEATURE_AVX2 1 1020 | # endif 1021 | # endif 1022 | # endif 1023 | #endif 1024 | #if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) 1025 | # error "unexpected configuration - check your compiler defines" 1026 | #endif 1027 | #if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) 1028 | # error "unexpected configuration - check your compiler defines" 1029 | #endif 1030 | #if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) 1031 | # error "unexpected configuration - check your compiler defines" 1032 | #endif 1033 | #if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) 1034 | # error "unexpected configuration - check your compiler defines" 1035 | #endif 1036 | #if (LZO_ARCH_ARM) 1037 | # if !defined(LZO_TARGET_FEATURE_NEON) 1038 | # if defined(__ARM_NEON) && ((__ARM_NEON)+0) 1039 | # define LZO_TARGET_FEATURE_NEON 1 1040 | # elif 1 && defined(__ARM_NEON__) && ((__ARM_NEON__)+0) 1041 | # define LZO_TARGET_FEATURE_NEON 1 1042 | # elif 1 && defined(__TARGET_FEATURE_NEON) && ((__TARGET_FEATURE_NEON)+0) 1043 | # define LZO_TARGET_FEATURE_NEON 1 1044 | # endif 1045 | # endif 1046 | #elif (LZO_ARCH_ARM64) 1047 | # if !defined(LZO_TARGET_FEATURE_NEON) 1048 | # if 1 1049 | # define LZO_TARGET_FEATURE_NEON 1 1050 | # endif 1051 | # endif 1052 | #endif 1053 | #if 0 1054 | #elif !defined(__LZO_MM_OVERRIDE) 1055 | #if (LZO_ARCH_I086) 1056 | #if (UINT_MAX != LZO_0xffffL) 1057 | # error "unexpected configuration - check your compiler defines" 1058 | #endif 1059 | #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) 1060 | # define LZO_MM_TINY 1 1061 | #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) 1062 | # define LZO_MM_HUGE 1 1063 | #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) 1064 | # define LZO_MM_SMALL 1 1065 | #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) 1066 | # define LZO_MM_MEDIUM 1 1067 | #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) 1068 | # define LZO_MM_COMPACT 1 1069 | #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) 1070 | # define LZO_MM_LARGE 1 1071 | #elif (LZO_CC_AZTECC) 1072 | # if defined(_LARGE_CODE) && defined(_LARGE_DATA) 1073 | # define LZO_MM_LARGE 1 1074 | # elif defined(_LARGE_CODE) 1075 | # define LZO_MM_MEDIUM 1 1076 | # elif defined(_LARGE_DATA) 1077 | # define LZO_MM_COMPACT 1 1078 | # else 1079 | # define LZO_MM_SMALL 1 1080 | # endif 1081 | #elif (LZO_CC_ZORTECHC && defined(__VCM__)) 1082 | # define LZO_MM_LARGE 1 1083 | #else 1084 | # error "unknown LZO_ARCH_I086 memory model" 1085 | #endif 1086 | #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) 1087 | #define LZO_HAVE_MM_HUGE_PTR 1 1088 | #define LZO_HAVE_MM_HUGE_ARRAY 1 1089 | #if (LZO_MM_TINY) 1090 | # undef LZO_HAVE_MM_HUGE_ARRAY 1091 | #endif 1092 | #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) 1093 | # undef LZO_HAVE_MM_HUGE_PTR 1094 | # undef LZO_HAVE_MM_HUGE_ARRAY 1095 | #elif (LZO_CC_DMC || LZO_CC_SYMANTECC) 1096 | # undef LZO_HAVE_MM_HUGE_ARRAY 1097 | #elif (LZO_CC_MSC && defined(_QC)) 1098 | # undef LZO_HAVE_MM_HUGE_ARRAY 1099 | # if (_MSC_VER < 600) 1100 | # undef LZO_HAVE_MM_HUGE_PTR 1101 | # endif 1102 | #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) 1103 | # undef LZO_HAVE_MM_HUGE_ARRAY 1104 | #endif 1105 | #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) 1106 | # if (LZO_OS_DOS16) 1107 | # error "unexpected configuration - check your compiler defines" 1108 | # elif (LZO_CC_ZORTECHC) 1109 | # else 1110 | # error "unexpected configuration - check your compiler defines" 1111 | # endif 1112 | #endif 1113 | #ifdef __cplusplus 1114 | extern "C" { 1115 | #endif 1116 | #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) 1117 | extern void __near __cdecl _AHSHIFT(void); 1118 | # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 1119 | #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) 1120 | extern void __near __cdecl _AHSHIFT(void); 1121 | # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 1122 | #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) 1123 | extern void __near __cdecl _AHSHIFT(void); 1124 | # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 1125 | #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) 1126 | extern void __near __cdecl _AHSHIFT(void); 1127 | # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) 1128 | #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) 1129 | # define LZO_MM_AHSHIFT 12 1130 | #elif (LZO_CC_WATCOMC) 1131 | extern unsigned char _HShift; 1132 | # define LZO_MM_AHSHIFT ((unsigned) _HShift) 1133 | #else 1134 | # error "FIXME - implement LZO_MM_AHSHIFT" 1135 | #endif 1136 | #ifdef __cplusplus 1137 | } 1138 | #endif 1139 | #endif 1140 | #elif (LZO_ARCH_C166) 1141 | #if !defined(__MODEL__) 1142 | # error "FIXME - LZO_ARCH_C166 __MODEL__" 1143 | #elif ((__MODEL__) == 0) 1144 | # define LZO_MM_SMALL 1 1145 | #elif ((__MODEL__) == 1) 1146 | # define LZO_MM_SMALL 1 1147 | #elif ((__MODEL__) == 2) 1148 | # define LZO_MM_LARGE 1 1149 | #elif ((__MODEL__) == 3) 1150 | # define LZO_MM_TINY 1 1151 | #elif ((__MODEL__) == 4) 1152 | # define LZO_MM_XTINY 1 1153 | #elif ((__MODEL__) == 5) 1154 | # define LZO_MM_XSMALL 1 1155 | #else 1156 | # error "FIXME - LZO_ARCH_C166 __MODEL__" 1157 | #endif 1158 | #elif (LZO_ARCH_MCS251) 1159 | #if !defined(__MODEL__) 1160 | # error "FIXME - LZO_ARCH_MCS251 __MODEL__" 1161 | #elif ((__MODEL__) == 0) 1162 | # define LZO_MM_SMALL 1 1163 | #elif ((__MODEL__) == 2) 1164 | # define LZO_MM_LARGE 1 1165 | #elif ((__MODEL__) == 3) 1166 | # define LZO_MM_TINY 1 1167 | #elif ((__MODEL__) == 4) 1168 | # define LZO_MM_XTINY 1 1169 | #elif ((__MODEL__) == 5) 1170 | # define LZO_MM_XSMALL 1 1171 | #else 1172 | # error "FIXME - LZO_ARCH_MCS251 __MODEL__" 1173 | #endif 1174 | #elif (LZO_ARCH_MCS51) 1175 | #if !defined(__MODEL__) 1176 | # error "FIXME - LZO_ARCH_MCS51 __MODEL__" 1177 | #elif ((__MODEL__) == 1) 1178 | # define LZO_MM_SMALL 1 1179 | #elif ((__MODEL__) == 2) 1180 | # define LZO_MM_LARGE 1 1181 | #elif ((__MODEL__) == 3) 1182 | # define LZO_MM_TINY 1 1183 | #elif ((__MODEL__) == 4) 1184 | # define LZO_MM_XTINY 1 1185 | #elif ((__MODEL__) == 5) 1186 | # define LZO_MM_XSMALL 1 1187 | #else 1188 | # error "FIXME - LZO_ARCH_MCS51 __MODEL__" 1189 | #endif 1190 | #elif (LZO_ARCH_CRAY_PVP) 1191 | # define LZO_MM_PVP 1 1192 | #else 1193 | # define LZO_MM_FLAT 1 1194 | #endif 1195 | #if (LZO_MM_COMPACT) 1196 | # define LZO_INFO_MM "compact" 1197 | #elif (LZO_MM_FLAT) 1198 | # define LZO_INFO_MM "flat" 1199 | #elif (LZO_MM_HUGE) 1200 | # define LZO_INFO_MM "huge" 1201 | #elif (LZO_MM_LARGE) 1202 | # define LZO_INFO_MM "large" 1203 | #elif (LZO_MM_MEDIUM) 1204 | # define LZO_INFO_MM "medium" 1205 | #elif (LZO_MM_PVP) 1206 | # define LZO_INFO_MM "pvp" 1207 | #elif (LZO_MM_SMALL) 1208 | # define LZO_INFO_MM "small" 1209 | #elif (LZO_MM_TINY) 1210 | # define LZO_INFO_MM "tiny" 1211 | #else 1212 | # error "unknown memory model" 1213 | #endif 1214 | #endif 1215 | #if !defined(__lzo_gnuc_extension__) 1216 | #if (LZO_CC_GNUC >= 0x020800ul) 1217 | # define __lzo_gnuc_extension__ __extension__ 1218 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1219 | # define __lzo_gnuc_extension__ __extension__ 1220 | #elif (LZO_CC_IBMC >= 600) 1221 | # define __lzo_gnuc_extension__ __extension__ 1222 | #else 1223 | #endif 1224 | #endif 1225 | #if !defined(__lzo_gnuc_extension__) 1226 | # define __lzo_gnuc_extension__ /*empty*/ 1227 | #endif 1228 | #if !defined(lzo_has_builtin) 1229 | #if (LZO_CC_CLANG) && defined(__has_builtin) 1230 | # define lzo_has_builtin __has_builtin 1231 | #endif 1232 | #endif 1233 | #if !defined(lzo_has_builtin) 1234 | # define lzo_has_builtin(x) 0 1235 | #endif 1236 | #if !defined(lzo_has_attribute) 1237 | #if (LZO_CC_CLANG) && defined(__has_attribute) 1238 | # define lzo_has_attribute __has_attribute 1239 | #endif 1240 | #endif 1241 | #if !defined(lzo_has_attribute) 1242 | # define lzo_has_attribute(x) 0 1243 | #endif 1244 | #if !defined(lzo_has_declspec_attribute) 1245 | #if (LZO_CC_CLANG) && defined(__has_declspec_attribute) 1246 | # define lzo_has_declspec_attribute __has_declspec_attribute 1247 | #endif 1248 | #endif 1249 | #if !defined(lzo_has_declspec_attribute) 1250 | # define lzo_has_declspec_attribute(x) 0 1251 | #endif 1252 | #if !defined(lzo_has_feature) 1253 | #if (LZO_CC_CLANG) && defined(__has_feature) 1254 | # define lzo_has_feature __has_feature 1255 | #endif 1256 | #endif 1257 | #if !defined(lzo_has_feature) 1258 | # define lzo_has_feature(x) 0 1259 | #endif 1260 | #if !defined(lzo_has_extension) 1261 | #if (LZO_CC_CLANG) && defined(__has_extension) 1262 | # define lzo_has_extension __has_extension 1263 | #elif (LZO_CC_CLANG) && defined(__has_feature) 1264 | # define lzo_has_extension __has_feature 1265 | #endif 1266 | #endif 1267 | #if !defined(lzo_has_extension) 1268 | # define lzo_has_extension 0 1269 | #endif 1270 | #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 1271 | # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) 1272 | # define LZO_CFG_USE_NEW_STYLE_CASTS 0 1273 | # elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) 1274 | # define LZO_CFG_USE_NEW_STYLE_CASTS 0 1275 | # else 1276 | # define LZO_CFG_USE_NEW_STYLE_CASTS 1 1277 | # endif 1278 | #endif 1279 | #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) 1280 | # define LZO_CFG_USE_NEW_STYLE_CASTS 0 1281 | #endif 1282 | #if !defined(__cplusplus) 1283 | # if defined(LZO_CFG_USE_NEW_STYLE_CASTS) 1284 | # undef LZO_CFG_USE_NEW_STYLE_CASTS 1285 | # endif 1286 | # define LZO_CFG_USE_NEW_STYLE_CASTS 0 1287 | #endif 1288 | #if !defined(LZO_REINTERPRET_CAST) 1289 | # if (LZO_CFG_USE_NEW_STYLE_CASTS) 1290 | # define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) 1291 | # endif 1292 | #endif 1293 | #if !defined(LZO_REINTERPRET_CAST) 1294 | # define LZO_REINTERPRET_CAST(t,e) ((t) (e)) 1295 | #endif 1296 | #if !defined(LZO_STATIC_CAST) 1297 | # if (LZO_CFG_USE_NEW_STYLE_CASTS) 1298 | # define LZO_STATIC_CAST(t,e) (static_cast (e)) 1299 | # endif 1300 | #endif 1301 | #if !defined(LZO_STATIC_CAST) 1302 | # define LZO_STATIC_CAST(t,e) ((t) (e)) 1303 | #endif 1304 | #if !defined(LZO_STATIC_CAST2) 1305 | # define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) 1306 | #endif 1307 | #if !defined(LZO_UNCONST_CAST) 1308 | # if (LZO_CFG_USE_NEW_STYLE_CASTS) 1309 | # define LZO_UNCONST_CAST(t,e) (const_cast (e)) 1310 | # elif (LZO_HAVE_MM_HUGE_PTR) 1311 | # define LZO_UNCONST_CAST(t,e) ((t) (e)) 1312 | # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1313 | # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) 1314 | # endif 1315 | #endif 1316 | #if !defined(LZO_UNCONST_CAST) 1317 | # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) 1318 | #endif 1319 | #if !defined(LZO_UNCONST_VOLATILE_CAST) 1320 | # if (LZO_CFG_USE_NEW_STYLE_CASTS) 1321 | # define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) 1322 | # elif (LZO_HAVE_MM_HUGE_PTR) 1323 | # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) 1324 | # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1325 | # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) 1326 | # endif 1327 | #endif 1328 | #if !defined(LZO_UNCONST_VOLATILE_CAST) 1329 | # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) 1330 | #endif 1331 | #if !defined(LZO_UNVOLATILE_CAST) 1332 | # if (LZO_CFG_USE_NEW_STYLE_CASTS) 1333 | # define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) 1334 | # elif (LZO_HAVE_MM_HUGE_PTR) 1335 | # define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) 1336 | # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1337 | # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) 1338 | # endif 1339 | #endif 1340 | #if !defined(LZO_UNVOLATILE_CAST) 1341 | # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) 1342 | #endif 1343 | #if !defined(LZO_UNVOLATILE_CONST_CAST) 1344 | # if (LZO_CFG_USE_NEW_STYLE_CASTS) 1345 | # define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) 1346 | # elif (LZO_HAVE_MM_HUGE_PTR) 1347 | # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) 1348 | # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1349 | # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) 1350 | # endif 1351 | #endif 1352 | #if !defined(LZO_UNVOLATILE_CONST_CAST) 1353 | # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) 1354 | #endif 1355 | #if !defined(LZO_PCAST) 1356 | # if (LZO_HAVE_MM_HUGE_PTR) 1357 | # define LZO_PCAST(t,e) ((t) (e)) 1358 | # endif 1359 | #endif 1360 | #if !defined(LZO_PCAST) 1361 | # define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) 1362 | #endif 1363 | #if !defined(LZO_CCAST) 1364 | # if (LZO_HAVE_MM_HUGE_PTR) 1365 | # define LZO_CCAST(t,e) ((t) (e)) 1366 | # endif 1367 | #endif 1368 | #if !defined(LZO_CCAST) 1369 | # define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) 1370 | #endif 1371 | #if !defined(LZO_ICONV) 1372 | # define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) 1373 | #endif 1374 | #if !defined(LZO_ICAST) 1375 | # define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) 1376 | #endif 1377 | #if !defined(LZO_ITRUNC) 1378 | # define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) 1379 | #endif 1380 | #if !defined(__lzo_cte) 1381 | # if (LZO_CC_MSC || LZO_CC_WATCOMC) 1382 | # define __lzo_cte(e) ((void)0,(e)) 1383 | # elif 1 1384 | # define __lzo_cte(e) ((void)0,(e)) 1385 | # endif 1386 | #endif 1387 | #if !defined(__lzo_cte) 1388 | # define __lzo_cte(e) (e) 1389 | #endif 1390 | #if !defined(LZO_BLOCK_BEGIN) 1391 | # define LZO_BLOCK_BEGIN do { 1392 | # define LZO_BLOCK_END } while __lzo_cte(0) 1393 | #endif 1394 | #if !defined(LZO_UNUSED) 1395 | # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) 1396 | # define LZO_UNUSED(var) ((void) &var) 1397 | # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) 1398 | # define LZO_UNUSED(var) if (&var) ; else 1399 | # elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) 1400 | # define LZO_UNUSED(var) ((void) &var) 1401 | # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1402 | # define LZO_UNUSED(var) ((void) var) 1403 | # elif (LZO_CC_MSC && (_MSC_VER < 900)) 1404 | # define LZO_UNUSED(var) if (&var) ; else 1405 | # elif (LZO_CC_KEILC) 1406 | # define LZO_UNUSED(var) {extern int lzo_unused__[1-2*!(sizeof(var)>0)]; (void)lzo_unused__;} 1407 | # elif (LZO_CC_PACIFICC) 1408 | # define LZO_UNUSED(var) ((void) sizeof(var)) 1409 | # elif (LZO_CC_WATCOMC) && defined(__cplusplus) 1410 | # define LZO_UNUSED(var) ((void) var) 1411 | # else 1412 | # define LZO_UNUSED(var) ((void) &var) 1413 | # endif 1414 | #endif 1415 | #if !defined(LZO_UNUSED_FUNC) 1416 | # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) 1417 | # define LZO_UNUSED_FUNC(func) ((void) func) 1418 | # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) 1419 | # define LZO_UNUSED_FUNC(func) if (func) ; else 1420 | # elif (LZO_CC_CLANG || LZO_CC_LLVM) 1421 | # define LZO_UNUSED_FUNC(func) ((void) &func) 1422 | # elif (LZO_CC_MSC && (_MSC_VER < 900)) 1423 | # define LZO_UNUSED_FUNC(func) if (func) ; else 1424 | # elif (LZO_CC_MSC) 1425 | # define LZO_UNUSED_FUNC(func) ((void) &func) 1426 | # elif (LZO_CC_KEILC || LZO_CC_PELLESC) 1427 | # define LZO_UNUSED_FUNC(func) {extern int lzo_unused__[1-2*!(sizeof((int)func)>0)]; (void)lzo_unused__;} 1428 | # else 1429 | # define LZO_UNUSED_FUNC(func) ((void) func) 1430 | # endif 1431 | #endif 1432 | #if !defined(LZO_UNUSED_LABEL) 1433 | # if (LZO_CC_CLANG >= 0x020800ul) 1434 | # define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) 1435 | # elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) 1436 | # define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l 1437 | # else 1438 | # define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l 1439 | # endif 1440 | #endif 1441 | #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) 1442 | # if 0 1443 | # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var 1444 | # elif 0 && (LZO_CC_GNUC) 1445 | # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var 1446 | # else 1447 | # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init 1448 | # endif 1449 | #endif 1450 | #if !defined(__lzo_inline) 1451 | #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) 1452 | #elif defined(__cplusplus) 1453 | # define __lzo_inline inline 1454 | #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) 1455 | # define __lzo_inline inline 1456 | #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) 1457 | # define __lzo_inline __inline 1458 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) 1459 | # define __lzo_inline __inline__ 1460 | #elif (LZO_CC_DMC) 1461 | # define __lzo_inline __inline 1462 | #elif (LZO_CC_GHS) 1463 | # define __lzo_inline __inline__ 1464 | #elif (LZO_CC_IBMC >= 600) 1465 | # define __lzo_inline __inline__ 1466 | #elif (LZO_CC_INTELC) 1467 | # define __lzo_inline __inline 1468 | #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) 1469 | # define __lzo_inline __inline 1470 | #elif (LZO_CC_MSC && (_MSC_VER >= 900)) 1471 | # define __lzo_inline __inline 1472 | #elif (LZO_CC_SUNPROC >= 0x5100) 1473 | # define __lzo_inline __inline__ 1474 | #endif 1475 | #endif 1476 | #if defined(__lzo_inline) 1477 | # ifndef __lzo_HAVE_inline 1478 | # define __lzo_HAVE_inline 1 1479 | # endif 1480 | #else 1481 | # define __lzo_inline /*empty*/ 1482 | #endif 1483 | #if !defined(__lzo_forceinline) 1484 | #if (LZO_CC_GNUC >= 0x030200ul) 1485 | # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1486 | #elif (LZO_CC_IBMC >= 700) 1487 | # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1488 | #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) 1489 | # define __lzo_forceinline __forceinline 1490 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) 1491 | # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1492 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1493 | # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1494 | #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) 1495 | # define __lzo_forceinline __forceinline 1496 | #elif (LZO_CC_PGI >= 0x0d0a00ul) 1497 | # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1498 | #elif (LZO_CC_SUNPROC >= 0x5100) 1499 | # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) 1500 | #endif 1501 | #endif 1502 | #if defined(__lzo_forceinline) 1503 | # ifndef __lzo_HAVE_forceinline 1504 | # define __lzo_HAVE_forceinline 1 1505 | # endif 1506 | #else 1507 | # define __lzo_forceinline __lzo_inline 1508 | #endif 1509 | #if !defined(__lzo_noinline) 1510 | #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) 1511 | # define __lzo_noinline __attribute__((__noinline__,__used__)) 1512 | #elif (LZO_CC_GNUC >= 0x030200ul) 1513 | # define __lzo_noinline __attribute__((__noinline__)) 1514 | #elif (LZO_CC_IBMC >= 700) 1515 | # define __lzo_noinline __attribute__((__noinline__)) 1516 | #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) 1517 | # define __lzo_noinline __declspec(noinline) 1518 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) 1519 | # define __lzo_noinline __attribute__((__noinline__)) 1520 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1521 | # define __lzo_noinline __attribute__((__noinline__)) 1522 | #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) 1523 | # define __lzo_noinline __declspec(noinline) 1524 | #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) 1525 | # if defined(__cplusplus) 1526 | # else 1527 | # define __lzo_noinline __declspec(noinline) 1528 | # endif 1529 | #elif (LZO_CC_PGI >= 0x0d0a00ul) 1530 | # define __lzo_noinline __attribute__((__noinline__)) 1531 | #elif (LZO_CC_SUNPROC >= 0x5100) 1532 | # define __lzo_noinline __attribute__((__noinline__)) 1533 | #endif 1534 | #endif 1535 | #if defined(__lzo_noinline) 1536 | # ifndef __lzo_HAVE_noinline 1537 | # define __lzo_HAVE_noinline 1 1538 | # endif 1539 | #else 1540 | # define __lzo_noinline /*empty*/ 1541 | #endif 1542 | #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) 1543 | # error "unexpected configuration - check your compiler defines" 1544 | #endif 1545 | #if !defined(__lzo_static_inline) 1546 | #if (LZO_CC_IBMC) 1547 | # define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline 1548 | #endif 1549 | #endif 1550 | #if !defined(__lzo_static_inline) 1551 | # define __lzo_static_inline static __lzo_inline 1552 | #endif 1553 | #if !defined(__lzo_static_forceinline) 1554 | #if (LZO_CC_IBMC) 1555 | # define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline 1556 | #endif 1557 | #endif 1558 | #if !defined(__lzo_static_forceinline) 1559 | # define __lzo_static_forceinline static __lzo_forceinline 1560 | #endif 1561 | #if !defined(__lzo_static_noinline) 1562 | #if (LZO_CC_IBMC) 1563 | # define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline 1564 | #endif 1565 | #endif 1566 | #if !defined(__lzo_static_noinline) 1567 | # define __lzo_static_noinline static __lzo_noinline 1568 | #endif 1569 | #if !defined(__lzo_c99_extern_inline) 1570 | #if defined(__GNUC_GNU_INLINE__) 1571 | # define __lzo_c99_extern_inline __lzo_inline 1572 | #elif defined(__GNUC_STDC_INLINE__) 1573 | # define __lzo_c99_extern_inline extern __lzo_inline 1574 | #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) 1575 | # define __lzo_c99_extern_inline extern __lzo_inline 1576 | #endif 1577 | #if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) 1578 | # define __lzo_c99_extern_inline __lzo_inline 1579 | #endif 1580 | #endif 1581 | #if defined(__lzo_c99_extern_inline) 1582 | # ifndef __lzo_HAVE_c99_extern_inline 1583 | # define __lzo_HAVE_c99_extern_inline 1 1584 | # endif 1585 | #else 1586 | # define __lzo_c99_extern_inline /*empty*/ 1587 | #endif 1588 | #if !defined(__lzo_may_alias) 1589 | #if (LZO_CC_GNUC >= 0x030400ul) 1590 | # define __lzo_may_alias __attribute__((__may_alias__)) 1591 | #elif (LZO_CC_CLANG >= 0x020900ul) 1592 | # define __lzo_may_alias __attribute__((__may_alias__)) 1593 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 1594 | # define __lzo_may_alias __attribute__((__may_alias__)) 1595 | #elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 1596 | # define __lzo_may_alias __attribute__((__may_alias__)) 1597 | #endif 1598 | #endif 1599 | #if defined(__lzo_may_alias) 1600 | # ifndef __lzo_HAVE_may_alias 1601 | # define __lzo_HAVE_may_alias 1 1602 | # endif 1603 | #else 1604 | # define __lzo_may_alias /*empty*/ 1605 | #endif 1606 | #if !defined(__lzo_noreturn) 1607 | #if (LZO_CC_GNUC >= 0x020700ul) 1608 | # define __lzo_noreturn __attribute__((__noreturn__)) 1609 | #elif (LZO_CC_IBMC >= 700) 1610 | # define __lzo_noreturn __attribute__((__noreturn__)) 1611 | #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) 1612 | # define __lzo_noreturn __declspec(noreturn) 1613 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) 1614 | # define __lzo_noreturn __attribute__((__noreturn__)) 1615 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1616 | # define __lzo_noreturn __attribute__((__noreturn__)) 1617 | #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) 1618 | # define __lzo_noreturn __declspec(noreturn) 1619 | #elif (LZO_CC_PGI >= 0x0d0a00ul) 1620 | # define __lzo_noreturn __attribute__((__noreturn__)) 1621 | #endif 1622 | #endif 1623 | #if defined(__lzo_noreturn) 1624 | # ifndef __lzo_HAVE_noreturn 1625 | # define __lzo_HAVE_noreturn 1 1626 | # endif 1627 | #else 1628 | # define __lzo_noreturn /*empty*/ 1629 | #endif 1630 | #if !defined(__lzo_nothrow) 1631 | #if (LZO_CC_GNUC >= 0x030300ul) 1632 | # define __lzo_nothrow __attribute__((__nothrow__)) 1633 | #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) 1634 | # define __lzo_nothrow __declspec(nothrow) 1635 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) 1636 | # define __lzo_nothrow __attribute__((__nothrow__)) 1637 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1638 | # define __lzo_nothrow __attribute__((__nothrow__)) 1639 | #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) 1640 | # define __lzo_nothrow __declspec(nothrow) 1641 | #endif 1642 | #endif 1643 | #if defined(__lzo_nothrow) 1644 | # ifndef __lzo_HAVE_nothrow 1645 | # define __lzo_HAVE_nothrow 1 1646 | # endif 1647 | #else 1648 | # define __lzo_nothrow /*empty*/ 1649 | #endif 1650 | #if !defined(__lzo_restrict) 1651 | #if (LZO_CC_GNUC >= 0x030400ul) 1652 | # define __lzo_restrict __restrict__ 1653 | #elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) 1654 | # define __lzo_restrict __restrict__ 1655 | #elif (LZO_CC_IBMC >= 1210) 1656 | # define __lzo_restrict __restrict__ 1657 | #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) 1658 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) 1659 | # define __lzo_restrict __restrict__ 1660 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) 1661 | # define __lzo_restrict __restrict__ 1662 | #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) 1663 | # define __lzo_restrict __restrict 1664 | #elif (LZO_CC_PGI >= 0x0d0a00ul) 1665 | # define __lzo_restrict __restrict__ 1666 | #endif 1667 | #endif 1668 | #if defined(__lzo_restrict) 1669 | # ifndef __lzo_HAVE_restrict 1670 | # define __lzo_HAVE_restrict 1 1671 | # endif 1672 | #else 1673 | # define __lzo_restrict /*empty*/ 1674 | #endif 1675 | #if !defined(__lzo_alignof) 1676 | #if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) 1677 | # define __lzo_alignof(e) __alignof__(e) 1678 | #elif (LZO_CC_GHS) && !defined(__cplusplus) 1679 | # define __lzo_alignof(e) __alignof__(e) 1680 | #elif (LZO_CC_IBMC >= 600) 1681 | # define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) 1682 | #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) 1683 | # define __lzo_alignof(e) __alignof__(e) 1684 | #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) 1685 | # define __lzo_alignof(e) __alignof(e) 1686 | #elif (LZO_CC_SUNPROC >= 0x5100) 1687 | # define __lzo_alignof(e) __alignof__(e) 1688 | #endif 1689 | #endif 1690 | #if defined(__lzo_alignof) 1691 | # ifndef __lzo_HAVE_alignof 1692 | # define __lzo_HAVE_alignof 1 1693 | # endif 1694 | #endif 1695 | #if !defined(__lzo_struct_packed) 1696 | #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) 1697 | #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) 1698 | #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) 1699 | #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) 1700 | #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) 1701 | #elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) 1702 | # define __lzo_struct_packed(s) struct s { 1703 | # define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); 1704 | # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); 1705 | #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) 1706 | # define __lzo_struct_packed(s) struct s { 1707 | # define __lzo_struct_packed_end() } __attribute__((__packed__)); 1708 | # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); 1709 | #elif (LZO_CC_IBMC >= 700) 1710 | # define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { 1711 | # define __lzo_struct_packed_end() } __attribute__((__packed__)); 1712 | # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); 1713 | #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) 1714 | # define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { 1715 | # define __lzo_struct_packed_end() } __pragma(pack(pop)); 1716 | #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) 1717 | # define __lzo_struct_packed(s) _Packed struct s { 1718 | # define __lzo_struct_packed_end() }; 1719 | #endif 1720 | #endif 1721 | #if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) 1722 | # define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) 1723 | #endif 1724 | #if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) 1725 | # define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() 1726 | #endif 1727 | #if !defined(__lzo_byte_struct) 1728 | #if defined(__lzo_struct_packed) 1729 | # define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() 1730 | # define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() 1731 | #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) 1732 | # define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); 1733 | # define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); 1734 | #endif 1735 | #endif 1736 | #if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) 1737 | # define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) 1738 | #endif 1739 | #if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) 1740 | #if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) 1741 | #elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) 1742 | #elif (LZO_CC_CILLY || LZO_CC_PCC) 1743 | #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) 1744 | # define __lzo_struct_align16(s) struct __declspec(align(16)) s { 1745 | # define __lzo_struct_align16_end() }; 1746 | # define __lzo_struct_align32(s) struct __declspec(align(32)) s { 1747 | # define __lzo_struct_align32_end() }; 1748 | # define __lzo_struct_align64(s) struct __declspec(align(64)) s { 1749 | # define __lzo_struct_align64_end() }; 1750 | #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1751 | # define __lzo_struct_align16(s) struct s { 1752 | # define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); 1753 | # define __lzo_struct_align32(s) struct s { 1754 | # define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); 1755 | # define __lzo_struct_align64(s) struct s { 1756 | # define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); 1757 | #endif 1758 | #endif 1759 | #if !defined(__lzo_union_um) 1760 | #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) 1761 | #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) 1762 | #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) 1763 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) 1764 | #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) 1765 | #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) 1766 | #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) 1767 | # define __lzo_union_am(s) union s { 1768 | # define __lzo_union_am_end() } __lzo_may_alias; 1769 | # define __lzo_union_um(s) union s { 1770 | # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); 1771 | #elif (LZO_CC_IBMC >= 700) 1772 | # define __lzo_union_am(s) __lzo_gnuc_extension__ union s { 1773 | # define __lzo_union_am_end() } __lzo_may_alias; 1774 | # define __lzo_union_um(s) __lzo_gnuc_extension__ union s { 1775 | # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); 1776 | #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) 1777 | # define __lzo_union_um(s) __pragma(pack(push,1)) union s { 1778 | # define __lzo_union_um_end() } __pragma(pack(pop)); 1779 | #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) 1780 | # define __lzo_union_um(s) _Packed union s { 1781 | # define __lzo_union_um_end() }; 1782 | #endif 1783 | #endif 1784 | #if !defined(__lzo_union_am) 1785 | # define __lzo_union_am(s) union s { 1786 | # define __lzo_union_am_end() }; 1787 | #endif 1788 | #if !defined(__lzo_constructor) 1789 | #if (LZO_CC_GNUC >= 0x030400ul) 1790 | # define __lzo_constructor __attribute__((__constructor__,__used__)) 1791 | #elif (LZO_CC_GNUC >= 0x020700ul) 1792 | # define __lzo_constructor __attribute__((__constructor__)) 1793 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) 1794 | # define __lzo_constructor __attribute__((__constructor__,__used__)) 1795 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1796 | # define __lzo_constructor __attribute__((__constructor__)) 1797 | #endif 1798 | #endif 1799 | #if defined(__lzo_constructor) 1800 | # ifndef __lzo_HAVE_constructor 1801 | # define __lzo_HAVE_constructor 1 1802 | # endif 1803 | #endif 1804 | #if !defined(__lzo_destructor) 1805 | #if (LZO_CC_GNUC >= 0x030400ul) 1806 | # define __lzo_destructor __attribute__((__destructor__,__used__)) 1807 | #elif (LZO_CC_GNUC >= 0x020700ul) 1808 | # define __lzo_destructor __attribute__((__destructor__)) 1809 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) 1810 | # define __lzo_destructor __attribute__((__destructor__,__used__)) 1811 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1812 | # define __lzo_destructor __attribute__((__destructor__)) 1813 | #endif 1814 | #endif 1815 | #if defined(__lzo_destructor) 1816 | # ifndef __lzo_HAVE_destructor 1817 | # define __lzo_HAVE_destructor 1 1818 | # endif 1819 | #endif 1820 | #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) 1821 | # error "unexpected configuration - check your compiler defines" 1822 | #endif 1823 | #if !defined(__lzo_likely) && !defined(__lzo_unlikely) 1824 | #if (LZO_CC_GNUC >= 0x030200ul) 1825 | # define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1826 | # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1827 | #elif (LZO_CC_IBMC >= 1010) 1828 | # define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1829 | # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1830 | #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) 1831 | # define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1832 | # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1833 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) 1834 | # define __lzo_likely(e) (__builtin_expect(!!(e),1)) 1835 | # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) 1836 | #endif 1837 | #endif 1838 | #if defined(__lzo_likely) 1839 | # ifndef __lzo_HAVE_likely 1840 | # define __lzo_HAVE_likely 1 1841 | # endif 1842 | #else 1843 | # define __lzo_likely(e) (e) 1844 | #endif 1845 | #if defined(__lzo_very_likely) 1846 | # ifndef __lzo_HAVE_very_likely 1847 | # define __lzo_HAVE_very_likely 1 1848 | # endif 1849 | #else 1850 | # define __lzo_very_likely(e) __lzo_likely(e) 1851 | #endif 1852 | #if defined(__lzo_unlikely) 1853 | # ifndef __lzo_HAVE_unlikely 1854 | # define __lzo_HAVE_unlikely 1 1855 | # endif 1856 | #else 1857 | # define __lzo_unlikely(e) (e) 1858 | #endif 1859 | #if defined(__lzo_very_unlikely) 1860 | # ifndef __lzo_HAVE_very_unlikely 1861 | # define __lzo_HAVE_very_unlikely 1 1862 | # endif 1863 | #else 1864 | # define __lzo_very_unlikely(e) __lzo_unlikely(e) 1865 | #endif 1866 | #if !defined(__lzo_loop_forever) 1867 | # if (LZO_CC_IBMC) 1868 | # define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END 1869 | # else 1870 | # define __lzo_loop_forever() do { ; } while __lzo_cte(1) 1871 | # endif 1872 | #endif 1873 | #if !defined(__lzo_unreachable) 1874 | #if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) && lzo_has_builtin(__builtin_unreachable) 1875 | # define __lzo_unreachable() __builtin_unreachable(); 1876 | #elif (LZO_CC_GNUC >= 0x040500ul) 1877 | # define __lzo_unreachable() __builtin_unreachable(); 1878 | #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 1879 | # define __lzo_unreachable() __builtin_unreachable(); 1880 | #endif 1881 | #endif 1882 | #if defined(__lzo_unreachable) 1883 | # ifndef __lzo_HAVE_unreachable 1884 | # define __lzo_HAVE_unreachable 1 1885 | # endif 1886 | #else 1887 | # if 0 1888 | # define __lzo_unreachable() ((void)0); 1889 | # else 1890 | # define __lzo_unreachable() __lzo_loop_forever(); 1891 | # endif 1892 | #endif 1893 | #if !defined(lzo_unused_funcs_impl) 1894 | # if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) 1895 | # define lzo_unused_funcs_impl(r,f) static r __attribute__((__unused__)) f 1896 | # elif 1 && (LZO_CC_BORLANDC || LZO_CC_GNUC) 1897 | # define lzo_unused_funcs_impl(r,f) static r f 1898 | # else 1899 | # define lzo_unused_funcs_impl(r,f) __lzo_static_forceinline r f 1900 | # endif 1901 | #endif 1902 | #ifndef __LZO_CTA_NAME 1903 | #if (LZO_CFG_USE_COUNTER) 1904 | # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) 1905 | #else 1906 | # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) 1907 | #endif 1908 | #endif 1909 | #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) 1910 | # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) 1911 | # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END 1912 | # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) 1913 | # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END 1914 | # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) 1915 | # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END 1916 | # elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) 1917 | # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END 1918 | # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) 1919 | # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END 1920 | # else 1921 | # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END 1922 | # endif 1923 | #endif 1924 | #if !defined(LZO_COMPILE_TIME_ASSERT) 1925 | # if (LZO_CC_AZTECC) 1926 | # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} 1927 | # elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030000ul)) 1928 | # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} 1929 | # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) 1930 | # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; 1931 | # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) 1932 | # define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} 1933 | # elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) 1934 | # define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} 1935 | # elif (LZO_CC_GNUC >= 0x040700ul) 1936 | # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} 1937 | # elif (LZO_CC_MSC && (_MSC_VER < 900)) 1938 | # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; 1939 | # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) 1940 | # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; 1941 | # else 1942 | # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} 1943 | # endif 1944 | #endif 1945 | LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) 1946 | #if defined(__cplusplus) 1947 | extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } 1948 | #endif 1949 | LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) 1950 | #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) 1951 | # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) 1952 | # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) 1953 | # define __lzo_cdecl __cdecl 1954 | # define __lzo_cdecl_atexit /*empty*/ 1955 | # define __lzo_cdecl_main __cdecl 1956 | # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) 1957 | # define __lzo_cdecl_qsort __pascal 1958 | # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) 1959 | # define __lzo_cdecl_qsort _stdcall 1960 | # else 1961 | # define __lzo_cdecl_qsort __cdecl 1962 | # endif 1963 | # elif (LZO_CC_WATCOMC) 1964 | # define __lzo_cdecl __cdecl 1965 | # else 1966 | # define __lzo_cdecl __cdecl 1967 | # define __lzo_cdecl_atexit __cdecl 1968 | # define __lzo_cdecl_main __cdecl 1969 | # define __lzo_cdecl_qsort __cdecl 1970 | # endif 1971 | # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) 1972 | # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) 1973 | # define __lzo_cdecl_sighandler __pascal 1974 | # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) 1975 | # define __lzo_cdecl_sighandler _stdcall 1976 | # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) 1977 | # define __lzo_cdecl_sighandler __clrcall 1978 | # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) 1979 | # if defined(_DLL) 1980 | # define __lzo_cdecl_sighandler _far _cdecl _loadds 1981 | # elif defined(_MT) 1982 | # define __lzo_cdecl_sighandler _far _cdecl 1983 | # else 1984 | # define __lzo_cdecl_sighandler _cdecl 1985 | # endif 1986 | # else 1987 | # define __lzo_cdecl_sighandler __cdecl 1988 | # endif 1989 | #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) 1990 | # define __lzo_cdecl __cdecl 1991 | #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) 1992 | # define __lzo_cdecl cdecl 1993 | #endif 1994 | #if !defined(__lzo_cdecl) 1995 | # define __lzo_cdecl /*empty*/ 1996 | #endif 1997 | #if !defined(__lzo_cdecl_atexit) 1998 | # define __lzo_cdecl_atexit /*empty*/ 1999 | #endif 2000 | #if !defined(__lzo_cdecl_main) 2001 | # define __lzo_cdecl_main /*empty*/ 2002 | #endif 2003 | #if !defined(__lzo_cdecl_qsort) 2004 | # define __lzo_cdecl_qsort /*empty*/ 2005 | #endif 2006 | #if !defined(__lzo_cdecl_sighandler) 2007 | # define __lzo_cdecl_sighandler /*empty*/ 2008 | #endif 2009 | #if !defined(__lzo_cdecl_va) 2010 | # define __lzo_cdecl_va __lzo_cdecl 2011 | #endif 2012 | #if !(LZO_CFG_NO_WINDOWS_H) 2013 | #if !defined(LZO_HAVE_WINDOWS_H) 2014 | #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) 2015 | # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) 2016 | # elif ((LZO_OS_WIN32 && defined(__PW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul))) 2017 | # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) 2018 | # else 2019 | # define LZO_HAVE_WINDOWS_H 1 2020 | # endif 2021 | #endif 2022 | #endif 2023 | #endif 2024 | #ifndef LZO_SIZEOF_SHORT 2025 | #if defined(SIZEOF_SHORT) 2026 | # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) 2027 | #elif defined(__SIZEOF_SHORT__) 2028 | # define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) 2029 | #endif 2030 | #endif 2031 | #ifndef LZO_SIZEOF_INT 2032 | #if defined(SIZEOF_INT) 2033 | # define LZO_SIZEOF_INT (SIZEOF_INT) 2034 | #elif defined(__SIZEOF_INT__) 2035 | # define LZO_SIZEOF_INT (__SIZEOF_INT__) 2036 | #endif 2037 | #endif 2038 | #ifndef LZO_SIZEOF_LONG 2039 | #if defined(SIZEOF_LONG) 2040 | # define LZO_SIZEOF_LONG (SIZEOF_LONG) 2041 | #elif defined(__SIZEOF_LONG__) 2042 | # define LZO_SIZEOF_LONG (__SIZEOF_LONG__) 2043 | #endif 2044 | #endif 2045 | #ifndef LZO_SIZEOF_LONG_LONG 2046 | #if defined(SIZEOF_LONG_LONG) 2047 | # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) 2048 | #elif defined(__SIZEOF_LONG_LONG__) 2049 | # define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) 2050 | #endif 2051 | #endif 2052 | #ifndef LZO_SIZEOF___INT16 2053 | #if defined(SIZEOF___INT16) 2054 | # define LZO_SIZEOF___INT16 (SIZEOF___INT16) 2055 | #endif 2056 | #endif 2057 | #ifndef LZO_SIZEOF___INT32 2058 | #if defined(SIZEOF___INT32) 2059 | # define LZO_SIZEOF___INT32 (SIZEOF___INT32) 2060 | #endif 2061 | #endif 2062 | #ifndef LZO_SIZEOF___INT64 2063 | #if defined(SIZEOF___INT64) 2064 | # define LZO_SIZEOF___INT64 (SIZEOF___INT64) 2065 | #endif 2066 | #endif 2067 | #ifndef LZO_SIZEOF_VOID_P 2068 | #if defined(SIZEOF_VOID_P) 2069 | # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) 2070 | #elif defined(__SIZEOF_POINTER__) 2071 | # define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) 2072 | #endif 2073 | #endif 2074 | #ifndef LZO_SIZEOF_SIZE_T 2075 | #if defined(SIZEOF_SIZE_T) 2076 | # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) 2077 | #elif defined(__SIZEOF_SIZE_T__) 2078 | # define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) 2079 | #endif 2080 | #endif 2081 | #ifndef LZO_SIZEOF_PTRDIFF_T 2082 | #if defined(SIZEOF_PTRDIFF_T) 2083 | # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) 2084 | #elif defined(__SIZEOF_PTRDIFF_T__) 2085 | # define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) 2086 | #endif 2087 | #endif 2088 | #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) 2089 | #if !defined(LZO_SIZEOF_SHORT) 2090 | # if (LZO_ARCH_CRAY_PVP) 2091 | # define LZO_SIZEOF_SHORT 8 2092 | # elif (USHRT_MAX == LZO_0xffffL) 2093 | # define LZO_SIZEOF_SHORT 2 2094 | # elif (__LZO_LSR(USHRT_MAX,7) == 1) 2095 | # define LZO_SIZEOF_SHORT 1 2096 | # elif (__LZO_LSR(USHRT_MAX,15) == 1) 2097 | # define LZO_SIZEOF_SHORT 2 2098 | # elif (__LZO_LSR(USHRT_MAX,31) == 1) 2099 | # define LZO_SIZEOF_SHORT 4 2100 | # elif (__LZO_LSR(USHRT_MAX,63) == 1) 2101 | # define LZO_SIZEOF_SHORT 8 2102 | # elif (__LZO_LSR(USHRT_MAX,127) == 1) 2103 | # define LZO_SIZEOF_SHORT 16 2104 | # else 2105 | # error "LZO_SIZEOF_SHORT" 2106 | # endif 2107 | #endif 2108 | LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) 2109 | #if !defined(LZO_SIZEOF_INT) 2110 | # if (LZO_ARCH_CRAY_PVP) 2111 | # define LZO_SIZEOF_INT 8 2112 | # elif (UINT_MAX == LZO_0xffffL) 2113 | # define LZO_SIZEOF_INT 2 2114 | # elif (UINT_MAX == LZO_0xffffffffL) 2115 | # define LZO_SIZEOF_INT 4 2116 | # elif (__LZO_LSR(UINT_MAX,7) == 1) 2117 | # define LZO_SIZEOF_INT 1 2118 | # elif (__LZO_LSR(UINT_MAX,15) == 1) 2119 | # define LZO_SIZEOF_INT 2 2120 | # elif (__LZO_LSR(UINT_MAX,31) == 1) 2121 | # define LZO_SIZEOF_INT 4 2122 | # elif (__LZO_LSR(UINT_MAX,63) == 1) 2123 | # define LZO_SIZEOF_INT 8 2124 | # elif (__LZO_LSR(UINT_MAX,127) == 1) 2125 | # define LZO_SIZEOF_INT 16 2126 | # else 2127 | # error "LZO_SIZEOF_INT" 2128 | # endif 2129 | #endif 2130 | LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) 2131 | #if !defined(LZO_SIZEOF_LONG) 2132 | # if (ULONG_MAX == LZO_0xffffffffL) 2133 | # define LZO_SIZEOF_LONG 4 2134 | # elif (__LZO_LSR(ULONG_MAX,7) == 1) 2135 | # define LZO_SIZEOF_LONG 1 2136 | # elif (__LZO_LSR(ULONG_MAX,15) == 1) 2137 | # define LZO_SIZEOF_LONG 2 2138 | # elif (__LZO_LSR(ULONG_MAX,31) == 1) 2139 | # define LZO_SIZEOF_LONG 4 2140 | # elif (__LZO_LSR(ULONG_MAX,39) == 1) 2141 | # define LZO_SIZEOF_LONG 5 2142 | # elif (__LZO_LSR(ULONG_MAX,63) == 1) 2143 | # define LZO_SIZEOF_LONG 8 2144 | # elif (__LZO_LSR(ULONG_MAX,127) == 1) 2145 | # define LZO_SIZEOF_LONG 16 2146 | # else 2147 | # error "LZO_SIZEOF_LONG" 2148 | # endif 2149 | #endif 2150 | LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) 2151 | #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) 2152 | #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) 2153 | # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) 2154 | # if (LZO_CC_GNUC >= 0x030300ul) 2155 | # if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) 2156 | # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG 2157 | # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) 2158 | # define LZO_SIZEOF_LONG_LONG 4 2159 | # endif 2160 | # endif 2161 | # endif 2162 | #endif 2163 | #endif 2164 | #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) 2165 | #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) 2166 | #if (LZO_ARCH_I086 && LZO_CC_DMC) 2167 | #elif (LZO_CC_CILLY) && defined(__GNUC__) 2168 | # define LZO_SIZEOF_LONG_LONG 8 2169 | #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) 2170 | # define LZO_SIZEOF_LONG_LONG 8 2171 | #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) 2172 | # define LZO_SIZEOF_LONG_LONG 8 2173 | #elif (LZO_OS_WIN64 || defined(_WIN64)) 2174 | # define LZO_SIZEOF___INT64 8 2175 | #elif (LZO_ARCH_I386 && (LZO_CC_DMC)) 2176 | # define LZO_SIZEOF_LONG_LONG 8 2177 | #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) 2178 | # define LZO_SIZEOF_LONG_LONG 8 2179 | #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) 2180 | # define LZO_SIZEOF_LONG_LONG 8 2181 | #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) 2182 | # define LZO_SIZEOF_LONG_LONG 8 2183 | #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) 2184 | # define LZO_SIZEOF___INT64 8 2185 | #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) 2186 | # define LZO_SIZEOF___INT64 8 2187 | #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) 2188 | # define LZO_SIZEOF___INT64 8 2189 | #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) 2190 | # define LZO_SIZEOF___INT64 8 2191 | #elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) 2192 | # define LZO_SIZEOF_LONG_LONG 8 2193 | #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) 2194 | # define LZO_SIZEOF___INT64 8 2195 | #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) 2196 | # define LZO_SIZEOF_LONG_LONG 8 2197 | #elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) 2198 | # define LZO_SIZEOF_LONG_LONG 8 2199 | #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) 2200 | #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) 2201 | # define LZO_SIZEOF_LONG_LONG 8 2202 | #endif 2203 | #endif 2204 | #endif 2205 | #if defined(__cplusplus) && (LZO_CC_GNUC) 2206 | # if (LZO_CC_GNUC < 0x020800ul) 2207 | # undef LZO_SIZEOF_LONG_LONG 2208 | # endif 2209 | #endif 2210 | #if (LZO_CFG_NO_LONG_LONG) 2211 | # undef LZO_SIZEOF_LONG_LONG 2212 | #elif defined(__NO_LONG_LONG) 2213 | # undef LZO_SIZEOF_LONG_LONG 2214 | #elif defined(_NO_LONGLONG) 2215 | # undef LZO_SIZEOF_LONG_LONG 2216 | #endif 2217 | #if !defined(LZO_WORDSIZE) 2218 | #if (LZO_ARCH_ALPHA) 2219 | # define LZO_WORDSIZE 8 2220 | #elif (LZO_ARCH_AMD64) 2221 | # define LZO_WORDSIZE 8 2222 | #elif (LZO_ARCH_AVR) 2223 | # define LZO_WORDSIZE 1 2224 | #elif (LZO_ARCH_H8300) 2225 | # if defined(__NORMAL_MODE__) 2226 | # define LZO_WORDSIZE 4 2227 | # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) 2228 | # define LZO_WORDSIZE 4 2229 | # else 2230 | # define LZO_WORDSIZE 2 2231 | # endif 2232 | #elif (LZO_ARCH_I086) 2233 | # define LZO_WORDSIZE 2 2234 | #elif (LZO_ARCH_IA64) 2235 | # define LZO_WORDSIZE 8 2236 | #elif (LZO_ARCH_M16C) 2237 | # define LZO_WORDSIZE 2 2238 | #elif (LZO_ARCH_SPU) 2239 | # define LZO_WORDSIZE 4 2240 | #elif (LZO_ARCH_Z80) 2241 | # define LZO_WORDSIZE 1 2242 | #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) 2243 | # define LZO_WORDSIZE 8 2244 | #elif (LZO_OS_OS400 || defined(__OS400__)) 2245 | # define LZO_WORDSIZE 8 2246 | #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) 2247 | # define LZO_WORDSIZE 8 2248 | #endif 2249 | #endif 2250 | #if !defined(LZO_SIZEOF_VOID_P) 2251 | #if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) 2252 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) 2253 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) 2254 | # define LZO_SIZEOF_VOID_P 4 2255 | #elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) 2256 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) 2257 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) 2258 | # define LZO_SIZEOF_VOID_P 8 2259 | #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) 2260 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) 2261 | # define LZO_SIZEOF_VOID_P 8 2262 | #elif defined(__LP64__) || defined(__LP64) || defined(_LP64) 2263 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) 2264 | # define LZO_SIZEOF_VOID_P 8 2265 | #elif (LZO_ARCH_AVR) 2266 | # define LZO_SIZEOF_VOID_P 2 2267 | #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) 2268 | # define LZO_SIZEOF_VOID_P 2 2269 | #elif (LZO_ARCH_H8300) 2270 | # if defined(__NORMAL_MODE__) 2271 | # define LZO_SIZEOF_VOID_P 2 2272 | # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) 2273 | # define LZO_SIZEOF_VOID_P 4 2274 | # else 2275 | # define LZO_SIZEOF_VOID_P 2 2276 | # endif 2277 | # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) 2278 | # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT 2279 | # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT 2280 | # endif 2281 | #elif (LZO_ARCH_I086) 2282 | # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) 2283 | # define LZO_SIZEOF_VOID_P 2 2284 | # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) 2285 | # define LZO_SIZEOF_VOID_P 4 2286 | # else 2287 | # error "invalid LZO_ARCH_I086 memory model" 2288 | # endif 2289 | #elif (LZO_ARCH_M16C) 2290 | # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) 2291 | # define LZO_SIZEOF_VOID_P 4 2292 | # else 2293 | # define LZO_SIZEOF_VOID_P 2 2294 | # endif 2295 | #elif (LZO_ARCH_SPU) 2296 | # define LZO_SIZEOF_VOID_P 4 2297 | #elif (LZO_ARCH_Z80) 2298 | # define LZO_SIZEOF_VOID_P 2 2299 | #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) 2300 | # define LZO_SIZEOF_VOID_P 4 2301 | #elif (LZO_OS_OS400 || defined(__OS400__)) 2302 | # if defined(__LLP64_IFC__) 2303 | # define LZO_SIZEOF_VOID_P 8 2304 | # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG 2305 | # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG 2306 | # else 2307 | # define LZO_SIZEOF_VOID_P 16 2308 | # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG 2309 | # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG 2310 | # endif 2311 | #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) 2312 | # define LZO_SIZEOF_VOID_P 8 2313 | # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG 2314 | # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG 2315 | #endif 2316 | #endif 2317 | #if !defined(LZO_SIZEOF_VOID_P) 2318 | # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG 2319 | #endif 2320 | LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) 2321 | #if !defined(LZO_SIZEOF_SIZE_T) 2322 | #if (LZO_ARCH_I086 || LZO_ARCH_M16C) 2323 | # define LZO_SIZEOF_SIZE_T 2 2324 | #endif 2325 | #endif 2326 | #if !defined(LZO_SIZEOF_SIZE_T) 2327 | # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P 2328 | #endif 2329 | #if defined(offsetof) 2330 | LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) 2331 | #endif 2332 | #if !defined(LZO_SIZEOF_PTRDIFF_T) 2333 | #if (LZO_ARCH_I086) 2334 | # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) 2335 | # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P 2336 | # elif (LZO_MM_COMPACT || LZO_MM_LARGE) 2337 | # if (LZO_CC_BORLANDC || LZO_CC_TURBOC) 2338 | # define LZO_SIZEOF_PTRDIFF_T 4 2339 | # else 2340 | # define LZO_SIZEOF_PTRDIFF_T 2 2341 | # endif 2342 | # else 2343 | # error "invalid LZO_ARCH_I086 memory model" 2344 | # endif 2345 | #endif 2346 | #endif 2347 | #if !defined(LZO_SIZEOF_PTRDIFF_T) 2348 | # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T 2349 | #endif 2350 | #if defined(offsetof) 2351 | LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) 2352 | #endif 2353 | #if !defined(LZO_WORDSIZE) 2354 | # define LZO_WORDSIZE LZO_SIZEOF_VOID_P 2355 | #endif 2356 | #if (LZO_ABI_NEUTRAL_ENDIAN) 2357 | # undef LZO_ABI_BIG_ENDIAN 2358 | # undef LZO_ABI_LITTLE_ENDIAN 2359 | #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) 2360 | #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) 2361 | # define LZO_ABI_BIG_ENDIAN 1 2362 | #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) 2363 | # define LZO_ABI_LITTLE_ENDIAN 1 2364 | #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) 2365 | # define LZO_ABI_LITTLE_ENDIAN 1 2366 | #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) 2367 | # define LZO_ABI_BIG_ENDIAN 1 2368 | #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) 2369 | # if (__LITTLE_ENDIAN__ == 1) 2370 | # define LZO_ABI_LITTLE_ENDIAN 1 2371 | # else 2372 | # define LZO_ABI_BIG_ENDIAN 1 2373 | # endif 2374 | #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) 2375 | # define LZO_ABI_BIG_ENDIAN 1 2376 | #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) 2377 | # define LZO_ABI_LITTLE_ENDIAN 1 2378 | #elif 1 && (LZO_ARCH_ARM) && defined(__ARM_BIG_ENDIAN) && ((__ARM_BIG_ENDIAN)+0) 2379 | # define LZO_ABI_BIG_ENDIAN 1 2380 | #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) 2381 | # define LZO_ABI_BIG_ENDIAN 1 2382 | #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) 2383 | # define LZO_ABI_LITTLE_ENDIAN 1 2384 | #elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) 2385 | # if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) 2386 | # error "unexpected configuration - check your compiler defines" 2387 | # elif defined(__BIG_ENDIAN) 2388 | # define LZO_ABI_BIG_ENDIAN 1 2389 | # else 2390 | # define LZO_ABI_LITTLE_ENDIAN 1 2391 | # endif 2392 | # define LZO_ABI_LITTLE_ENDIAN 1 2393 | #elif 1 && (LZO_ARCH_ARM64) && defined(__ARM_BIG_ENDIAN) && ((__ARM_BIG_ENDIAN)+0) 2394 | # define LZO_ABI_BIG_ENDIAN 1 2395 | #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) 2396 | # define LZO_ABI_BIG_ENDIAN 1 2397 | #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) 2398 | # define LZO_ABI_LITTLE_ENDIAN 1 2399 | #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) 2400 | # define LZO_ABI_BIG_ENDIAN 1 2401 | #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) 2402 | # define LZO_ABI_LITTLE_ENDIAN 1 2403 | #endif 2404 | #endif 2405 | #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) 2406 | # error "unexpected configuration - check your compiler defines" 2407 | #endif 2408 | #if (LZO_ABI_BIG_ENDIAN) 2409 | # define LZO_INFO_ABI_ENDIAN "be" 2410 | #elif (LZO_ABI_LITTLE_ENDIAN) 2411 | # define LZO_INFO_ABI_ENDIAN "le" 2412 | #elif (LZO_ABI_NEUTRAL_ENDIAN) 2413 | # define LZO_INFO_ABI_ENDIAN "neutral" 2414 | #endif 2415 | #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) 2416 | # define LZO_ABI_I8LP16 1 2417 | # define LZO_INFO_ABI_PM "i8lp16" 2418 | #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) 2419 | # define LZO_ABI_ILP16 1 2420 | # define LZO_INFO_ABI_PM "ilp16" 2421 | #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) 2422 | # define LZO_ABI_LP32 1 2423 | # define LZO_INFO_ABI_PM "lp32" 2424 | #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) 2425 | # define LZO_ABI_ILP32 1 2426 | # define LZO_INFO_ABI_PM "ilp32" 2427 | #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) 2428 | # define LZO_ABI_LLP64 1 2429 | # define LZO_INFO_ABI_PM "llp64" 2430 | #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) 2431 | # define LZO_ABI_LP64 1 2432 | # define LZO_INFO_ABI_PM "lp64" 2433 | #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) 2434 | # define LZO_ABI_ILP64 1 2435 | # define LZO_INFO_ABI_PM "ilp64" 2436 | #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) 2437 | # define LZO_ABI_IP32L64 1 2438 | # define LZO_INFO_ABI_PM "ip32l64" 2439 | #endif 2440 | #if 0 2441 | #elif !defined(__LZO_LIBC_OVERRIDE) 2442 | #if (LZO_LIBC_NAKED) 2443 | # define LZO_INFO_LIBC "naked" 2444 | #elif (LZO_LIBC_FREESTANDING) 2445 | # define LZO_INFO_LIBC "freestanding" 2446 | #elif (LZO_LIBC_MOSTLY_FREESTANDING) 2447 | # define LZO_INFO_LIBC "mfreestanding" 2448 | #elif (LZO_LIBC_ISOC90) 2449 | # define LZO_INFO_LIBC "isoc90" 2450 | #elif (LZO_LIBC_ISOC99) 2451 | # define LZO_INFO_LIBC "isoc99" 2452 | #elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) 2453 | # define LZO_LIBC_ISOC90 1 2454 | # define LZO_INFO_LIBC "isoc90" 2455 | #elif defined(__dietlibc__) 2456 | # define LZO_LIBC_DIETLIBC 1 2457 | # define LZO_INFO_LIBC "dietlibc" 2458 | #elif defined(_NEWLIB_VERSION) 2459 | # define LZO_LIBC_NEWLIB 1 2460 | # define LZO_INFO_LIBC "newlib" 2461 | #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) 2462 | # if defined(__UCLIBC_SUBLEVEL__) 2463 | # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) 2464 | # else 2465 | # define LZO_LIBC_UCLIBC 0x00090bL 2466 | # endif 2467 | # define LZO_INFO_LIBC "uc" "libc" 2468 | #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) 2469 | # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) 2470 | # define LZO_INFO_LIBC "glibc" 2471 | #elif (LZO_CC_MWERKS) && defined(__MSL__) 2472 | # define LZO_LIBC_MSL __MSL__ 2473 | # define LZO_INFO_LIBC "msl" 2474 | #elif 1 && defined(__IAR_SYSTEMS_ICC__) 2475 | # define LZO_LIBC_ISOC90 1 2476 | # define LZO_INFO_LIBC "isoc90" 2477 | #else 2478 | # define LZO_LIBC_DEFAULT 1 2479 | # define LZO_INFO_LIBC "default" 2480 | #endif 2481 | #endif 2482 | #if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) 2483 | # define LZO_ASM_SYNTAX_MSC 1 2484 | #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) 2485 | #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) 2486 | #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) 2487 | # define LZO_ASM_SYNTAX_GNUC 1 2488 | #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) 2489 | # define LZO_ASM_SYNTAX_GNUC 1 2490 | #elif (LZO_CC_GNUC) 2491 | # define LZO_ASM_SYNTAX_GNUC 1 2492 | #endif 2493 | #if (LZO_ASM_SYNTAX_GNUC) 2494 | #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) 2495 | # define __LZO_ASM_CLOBBER "ax" 2496 | # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ 2497 | # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ 2498 | # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ 2499 | #elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) 2500 | # define __LZO_ASM_CLOBBER "memory" 2501 | # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ 2502 | # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" 2503 | # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ 2504 | #else 2505 | # define __LZO_ASM_CLOBBER "cc", "memory" 2506 | # define __LZO_ASM_CLOBBER_LIST_CC : "cc" 2507 | # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" 2508 | # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ 2509 | #endif 2510 | #endif 2511 | #if (LZO_ARCH_ALPHA) 2512 | # define LZO_OPT_AVOID_UINT_INDEX 1 2513 | #elif (LZO_ARCH_AMD64) 2514 | # define LZO_OPT_AVOID_INT_INDEX 1 2515 | # define LZO_OPT_AVOID_UINT_INDEX 1 2516 | # ifndef LZO_OPT_UNALIGNED16 2517 | # define LZO_OPT_UNALIGNED16 1 2518 | # endif 2519 | # ifndef LZO_OPT_UNALIGNED32 2520 | # define LZO_OPT_UNALIGNED32 1 2521 | # endif 2522 | # ifndef LZO_OPT_UNALIGNED64 2523 | # define LZO_OPT_UNALIGNED64 1 2524 | # endif 2525 | #elif (LZO_ARCH_ARM) 2526 | # if defined(__ARM_FEATURE_UNALIGNED) 2527 | # if ((__ARM_FEATURE_UNALIGNED)+0) 2528 | # ifndef LZO_OPT_UNALIGNED16 2529 | # define LZO_OPT_UNALIGNED16 1 2530 | # endif 2531 | # ifndef LZO_OPT_UNALIGNED32 2532 | # define LZO_OPT_UNALIGNED32 1 2533 | # endif 2534 | # endif 2535 | # elif 1 && (LZO_ARCH_ARM_THUMB2) 2536 | # ifndef LZO_OPT_UNALIGNED16 2537 | # define LZO_OPT_UNALIGNED16 1 2538 | # endif 2539 | # ifndef LZO_OPT_UNALIGNED32 2540 | # define LZO_OPT_UNALIGNED32 1 2541 | # endif 2542 | # elif 1 && defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM)+0 >= 7) 2543 | # ifndef LZO_OPT_UNALIGNED16 2544 | # define LZO_OPT_UNALIGNED16 1 2545 | # endif 2546 | # ifndef LZO_OPT_UNALIGNED32 2547 | # define LZO_OPT_UNALIGNED32 1 2548 | # endif 2549 | # elif 1 && defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM)+0 >= 6) && (defined(__TARGET_PROFILE_A) || defined(__TARGET_PROFILE_R)) 2550 | # ifndef LZO_OPT_UNALIGNED16 2551 | # define LZO_OPT_UNALIGNED16 1 2552 | # endif 2553 | # ifndef LZO_OPT_UNALIGNED32 2554 | # define LZO_OPT_UNALIGNED32 1 2555 | # endif 2556 | # endif 2557 | #elif (LZO_ARCH_ARM64) 2558 | # ifndef LZO_OPT_UNALIGNED16 2559 | # define LZO_OPT_UNALIGNED16 1 2560 | # endif 2561 | # ifndef LZO_OPT_UNALIGNED32 2562 | # define LZO_OPT_UNALIGNED32 1 2563 | # endif 2564 | # ifndef LZO_OPT_UNALIGNED64 2565 | # define LZO_OPT_UNALIGNED64 1 2566 | # endif 2567 | #elif (LZO_ARCH_CRIS) 2568 | # ifndef LZO_OPT_UNALIGNED16 2569 | # define LZO_OPT_UNALIGNED16 1 2570 | # endif 2571 | # ifndef LZO_OPT_UNALIGNED32 2572 | # define LZO_OPT_UNALIGNED32 1 2573 | # endif 2574 | #elif (LZO_ARCH_I386) 2575 | # ifndef LZO_OPT_UNALIGNED16 2576 | # define LZO_OPT_UNALIGNED16 1 2577 | # endif 2578 | # ifndef LZO_OPT_UNALIGNED32 2579 | # define LZO_OPT_UNALIGNED32 1 2580 | # endif 2581 | #elif (LZO_ARCH_IA64) 2582 | # define LZO_OPT_AVOID_INT_INDEX 1 2583 | # define LZO_OPT_AVOID_UINT_INDEX 1 2584 | # define LZO_OPT_PREFER_POSTINC 1 2585 | #elif (LZO_ARCH_M68K) 2586 | # define LZO_OPT_PREFER_POSTINC 1 2587 | # define LZO_OPT_PREFER_PREDEC 1 2588 | # if defined(__mc68020__) && !defined(__mcoldfire__) 2589 | # ifndef LZO_OPT_UNALIGNED16 2590 | # define LZO_OPT_UNALIGNED16 1 2591 | # endif 2592 | # ifndef LZO_OPT_UNALIGNED32 2593 | # define LZO_OPT_UNALIGNED32 1 2594 | # endif 2595 | # endif 2596 | #elif (LZO_ARCH_MIPS) 2597 | # define LZO_OPT_AVOID_UINT_INDEX 1 2598 | #elif (LZO_ARCH_POWERPC) 2599 | # define LZO_OPT_PREFER_PREINC 1 2600 | # define LZO_OPT_PREFER_PREDEC 1 2601 | # if (LZO_ABI_BIG_ENDIAN) 2602 | # ifndef LZO_OPT_UNALIGNED16 2603 | # define LZO_OPT_UNALIGNED16 1 2604 | # endif 2605 | # ifndef LZO_OPT_UNALIGNED32 2606 | # define LZO_OPT_UNALIGNED32 1 2607 | # endif 2608 | # if (LZO_WORDSIZE == 8) 2609 | # ifndef LZO_OPT_UNALIGNED64 2610 | # define LZO_OPT_UNALIGNED64 1 2611 | # endif 2612 | # endif 2613 | # endif 2614 | #elif (LZO_ARCH_S390) 2615 | # ifndef LZO_OPT_UNALIGNED16 2616 | # define LZO_OPT_UNALIGNED16 1 2617 | # endif 2618 | # ifndef LZO_OPT_UNALIGNED32 2619 | # define LZO_OPT_UNALIGNED32 1 2620 | # endif 2621 | # if (LZO_WORDSIZE == 8) 2622 | # ifndef LZO_OPT_UNALIGNED64 2623 | # define LZO_OPT_UNALIGNED64 1 2624 | # endif 2625 | # endif 2626 | #elif (LZO_ARCH_SH) 2627 | # define LZO_OPT_PREFER_POSTINC 1 2628 | # define LZO_OPT_PREFER_PREDEC 1 2629 | #endif 2630 | #ifndef LZO_CFG_NO_INLINE_ASM 2631 | #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) 2632 | # define LZO_CFG_NO_INLINE_ASM 1 2633 | #elif (LZO_CC_LLVM) 2634 | # define LZO_CFG_NO_INLINE_ASM 1 2635 | #endif 2636 | #endif 2637 | #if (LZO_CFG_NO_INLINE_ASM) 2638 | # undef LZO_ASM_SYNTAX_MSC 2639 | # undef LZO_ASM_SYNTAX_GNUC 2640 | # undef __LZO_ASM_CLOBBER 2641 | # undef __LZO_ASM_CLOBBER_LIST_CC 2642 | # undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY 2643 | # undef __LZO_ASM_CLOBBER_LIST_EMPTY 2644 | #endif 2645 | #ifndef LZO_CFG_NO_UNALIGNED 2646 | #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) 2647 | # define LZO_CFG_NO_UNALIGNED 1 2648 | #endif 2649 | #endif 2650 | #if (LZO_CFG_NO_UNALIGNED) 2651 | # undef LZO_OPT_UNALIGNED16 2652 | # undef LZO_OPT_UNALIGNED32 2653 | # undef LZO_OPT_UNALIGNED64 2654 | #endif 2655 | #if defined(__LZO_INFOSTR_MM) 2656 | #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) 2657 | # define __LZO_INFOSTR_MM "" 2658 | #elif defined(LZO_INFO_MM) 2659 | # define __LZO_INFOSTR_MM "." LZO_INFO_MM 2660 | #else 2661 | # define __LZO_INFOSTR_MM "" 2662 | #endif 2663 | #if defined(__LZO_INFOSTR_PM) 2664 | #elif defined(LZO_INFO_ABI_PM) 2665 | # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM 2666 | #else 2667 | # define __LZO_INFOSTR_PM "" 2668 | #endif 2669 | #if defined(__LZO_INFOSTR_ENDIAN) 2670 | #elif defined(LZO_INFO_ABI_ENDIAN) 2671 | # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN 2672 | #else 2673 | # define __LZO_INFOSTR_ENDIAN "" 2674 | #endif 2675 | #if defined(__LZO_INFOSTR_OSNAME) 2676 | #elif defined(LZO_INFO_OS_CONSOLE) 2677 | # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE 2678 | #elif defined(LZO_INFO_OS_POSIX) 2679 | # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX 2680 | #else 2681 | # define __LZO_INFOSTR_OSNAME LZO_INFO_OS 2682 | #endif 2683 | #if defined(__LZO_INFOSTR_LIBC) 2684 | #elif defined(LZO_INFO_LIBC) 2685 | # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC 2686 | #else 2687 | # define __LZO_INFOSTR_LIBC "" 2688 | #endif 2689 | #if defined(__LZO_INFOSTR_CCVER) 2690 | #elif defined(LZO_INFO_CCVER) 2691 | # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER 2692 | #else 2693 | # define __LZO_INFOSTR_CCVER "" 2694 | #endif 2695 | #define LZO_INFO_STRING \ 2696 | LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ 2697 | " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER 2698 | #if !(LZO_CFG_SKIP_LZO_TYPES) 2699 | #if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) 2700 | # error "missing defines for sizes" 2701 | #endif 2702 | #if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) 2703 | # error "missing defines for sizes" 2704 | #endif 2705 | #define LZO_TYPEOF_CHAR 1u 2706 | #define LZO_TYPEOF_SHORT 2u 2707 | #define LZO_TYPEOF_INT 3u 2708 | #define LZO_TYPEOF_LONG 4u 2709 | #define LZO_TYPEOF_LONG_LONG 5u 2710 | #define LZO_TYPEOF___INT8 17u 2711 | #define LZO_TYPEOF___INT16 18u 2712 | #define LZO_TYPEOF___INT32 19u 2713 | #define LZO_TYPEOF___INT64 20u 2714 | #define LZO_TYPEOF___INT128 21u 2715 | #define LZO_TYPEOF___INT256 22u 2716 | #define LZO_TYPEOF___MODE_QI 33u 2717 | #define LZO_TYPEOF___MODE_HI 34u 2718 | #define LZO_TYPEOF___MODE_SI 35u 2719 | #define LZO_TYPEOF___MODE_DI 36u 2720 | #define LZO_TYPEOF___MODE_TI 37u 2721 | #define LZO_TYPEOF_CHAR_P 129u 2722 | #if !defined(lzo_llong_t) 2723 | #if (LZO_SIZEOF_LONG_LONG+0 > 0) 2724 | __lzo_gnuc_extension__ typedef long long lzo_llong_t__; 2725 | __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; 2726 | # define lzo_llong_t lzo_llong_t__ 2727 | # define lzo_ullong_t lzo_ullong_t__ 2728 | #endif 2729 | #endif 2730 | #if !defined(lzo_int16e_t) 2731 | #if (LZO_SIZEOF_LONG == 2) 2732 | # define lzo_int16e_t long 2733 | # define lzo_uint16e_t unsigned long 2734 | # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_LONG 2735 | #elif (LZO_SIZEOF_INT == 2) 2736 | # define lzo_int16e_t int 2737 | # define lzo_uint16e_t unsigned int 2738 | # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_INT 2739 | #elif (LZO_SIZEOF_SHORT == 2) 2740 | # define lzo_int16e_t short int 2741 | # define lzo_uint16e_t unsigned short int 2742 | # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_SHORT 2743 | #elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) 2744 | typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); 2745 | typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); 2746 | # define lzo_int16e_t lzo_int16e_hi_t__ 2747 | # define lzo_uint16e_t lzo_uint16e_hi_t__ 2748 | # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___MODE_HI 2749 | #elif (LZO_SIZEOF___INT16 == 2) 2750 | # define lzo_int16e_t __int16 2751 | # define lzo_uint16e_t unsigned __int16 2752 | # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___INT16 2753 | #else 2754 | #endif 2755 | #endif 2756 | #if defined(lzo_int16e_t) 2757 | # define LZO_SIZEOF_LZO_INT16E_T 2 2758 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) 2759 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) 2760 | #endif 2761 | #if !defined(lzo_int32e_t) 2762 | #if (LZO_SIZEOF_LONG == 4) 2763 | # define lzo_int32e_t long int 2764 | # define lzo_uint32e_t unsigned long int 2765 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG 2766 | #elif (LZO_SIZEOF_INT == 4) 2767 | # define lzo_int32e_t int 2768 | # define lzo_uint32e_t unsigned int 2769 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_INT 2770 | #elif (LZO_SIZEOF_SHORT == 4) 2771 | # define lzo_int32e_t short int 2772 | # define lzo_uint32e_t unsigned short int 2773 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_SHORT 2774 | #elif (LZO_SIZEOF_LONG_LONG == 4) 2775 | # define lzo_int32e_t lzo_llong_t 2776 | # define lzo_uint32e_t lzo_ullong_t 2777 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG_LONG 2778 | #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) 2779 | typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); 2780 | typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); 2781 | # define lzo_int32e_t lzo_int32e_si_t__ 2782 | # define lzo_uint32e_t lzo_uint32e_si_t__ 2783 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI 2784 | #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) 2785 | typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); 2786 | typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); 2787 | # define lzo_int32e_t lzo_int32e_si_t__ 2788 | # define lzo_uint32e_t lzo_uint32e_si_t__ 2789 | # define LZO_INT32_C(c) (c##LL) 2790 | # define LZO_UINT32_C(c) (c##ULL) 2791 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI 2792 | #elif (LZO_SIZEOF___INT32 == 4) 2793 | # define lzo_int32e_t __int32 2794 | # define lzo_uint32e_t unsigned __int32 2795 | # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___INT32 2796 | #else 2797 | #endif 2798 | #endif 2799 | #if defined(lzo_int32e_t) 2800 | # define LZO_SIZEOF_LZO_INT32E_T 4 2801 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) 2802 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) 2803 | #endif 2804 | #if !defined(lzo_int64e_t) 2805 | #if (LZO_SIZEOF___INT64 == 8) 2806 | # if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) 2807 | # define LZO_CFG_TYPE_PREFER___INT64 1 2808 | # endif 2809 | #endif 2810 | #if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) 2811 | # define lzo_int64e_t int 2812 | # define lzo_uint64e_t unsigned int 2813 | # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_INT 2814 | #elif (LZO_SIZEOF_LONG == 8) 2815 | # define lzo_int64e_t long int 2816 | # define lzo_uint64e_t unsigned long int 2817 | # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_LONG 2818 | #elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) 2819 | # define lzo_int64e_t lzo_llong_t 2820 | # define lzo_uint64e_t lzo_ullong_t 2821 | # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_LONG_LONG 2822 | # if (LZO_CC_BORLANDC) 2823 | # define LZO_INT64_C(c) ((c) + 0ll) 2824 | # define LZO_UINT64_C(c) ((c) + 0ull) 2825 | # elif 0 2826 | # define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) 2827 | # define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) 2828 | # else 2829 | # define LZO_INT64_C(c) (c##LL) 2830 | # define LZO_UINT64_C(c) (c##ULL) 2831 | # endif 2832 | #elif (LZO_SIZEOF___INT64 == 8) 2833 | # define lzo_int64e_t __int64 2834 | # define lzo_uint64e_t unsigned __int64 2835 | # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF___INT64 2836 | # if (LZO_CC_BORLANDC) 2837 | # define LZO_INT64_C(c) ((c) + 0i64) 2838 | # define LZO_UINT64_C(c) ((c) + 0ui64) 2839 | # else 2840 | # define LZO_INT64_C(c) (c##i64) 2841 | # define LZO_UINT64_C(c) (c##ui64) 2842 | # endif 2843 | #else 2844 | #endif 2845 | #endif 2846 | #if defined(lzo_int64e_t) 2847 | # define LZO_SIZEOF_LZO_INT64E_T 8 2848 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) 2849 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) 2850 | #endif 2851 | #if !defined(lzo_int32l_t) 2852 | #if defined(lzo_int32e_t) 2853 | # define lzo_int32l_t lzo_int32e_t 2854 | # define lzo_uint32l_t lzo_uint32e_t 2855 | # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T 2856 | # define LZO_TYPEOF_LZO_INT32L_T LZO_TYPEOF_LZO_INT32E_T 2857 | #elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) 2858 | # define lzo_int32l_t int 2859 | # define lzo_uint32l_t unsigned int 2860 | # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT 2861 | # define LZO_TYPEOF_LZO_INT32L_T LZO_SIZEOF_INT 2862 | #elif (LZO_SIZEOF_LONG >= 4) 2863 | # define lzo_int32l_t long int 2864 | # define lzo_uint32l_t unsigned long int 2865 | # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG 2866 | # define LZO_TYPEOF_LZO_INT32L_T LZO_SIZEOF_LONG 2867 | #else 2868 | # error "lzo_int32l_t" 2869 | #endif 2870 | #endif 2871 | #if 1 2872 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) 2873 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) 2874 | #endif 2875 | #if !defined(lzo_int64l_t) 2876 | #if defined(lzo_int64e_t) 2877 | # define lzo_int64l_t lzo_int64e_t 2878 | # define lzo_uint64l_t lzo_uint64e_t 2879 | # define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T 2880 | # define LZO_TYPEOF_LZO_INT64L_T LZO_TYPEOF_LZO_INT64E_T 2881 | #else 2882 | #endif 2883 | #endif 2884 | #if defined(lzo_int64l_t) 2885 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) 2886 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) 2887 | #endif 2888 | #if !defined(lzo_int32f_t) 2889 | #if (LZO_SIZEOF_SIZE_T >= 8) 2890 | # define lzo_int32f_t lzo_int64l_t 2891 | # define lzo_uint32f_t lzo_uint64l_t 2892 | # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T 2893 | # define LZO_TYPEOF_LZO_INT32F_T LZO_TYPEOF_LZO_INT64L_T 2894 | #else 2895 | # define lzo_int32f_t lzo_int32l_t 2896 | # define lzo_uint32f_t lzo_uint32l_t 2897 | # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T 2898 | # define LZO_TYPEOF_LZO_INT32F_T LZO_TYPEOF_LZO_INT32L_T 2899 | #endif 2900 | #endif 2901 | #if 1 2902 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) 2903 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) 2904 | #endif 2905 | #if !defined(lzo_int64f_t) 2906 | #if defined(lzo_int64l_t) 2907 | # define lzo_int64f_t lzo_int64l_t 2908 | # define lzo_uint64f_t lzo_uint64l_t 2909 | # define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T 2910 | # define LZO_TYPEOF_LZO_INT64F_T LZO_TYPEOF_LZO_INT64L_T 2911 | #else 2912 | #endif 2913 | #endif 2914 | #if defined(lzo_int64f_t) 2915 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) 2916 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) 2917 | #endif 2918 | #if !defined(lzo_intptr_t) 2919 | #if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) 2920 | # define __LZO_INTPTR_T_IS_POINTER 1 2921 | typedef char * lzo_intptr_t; 2922 | typedef char * lzo_uintptr_t; 2923 | # define lzo_intptr_t lzo_intptr_t 2924 | # define lzo_uintptr_t lzo_uintptr_t 2925 | # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P 2926 | # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_CHAR_P 2927 | #elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) 2928 | typedef __w64 int lzo_intptr_t; 2929 | typedef __w64 unsigned int lzo_uintptr_t; 2930 | # define lzo_intptr_t lzo_intptr_t 2931 | # define lzo_uintptr_t lzo_uintptr_t 2932 | # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT 2933 | # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_INT 2934 | #elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) 2935 | # define lzo_intptr_t short 2936 | # define lzo_uintptr_t unsigned short 2937 | # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT 2938 | # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_SHORT 2939 | #elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) 2940 | # define lzo_intptr_t int 2941 | # define lzo_uintptr_t unsigned int 2942 | # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT 2943 | # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_INT 2944 | #elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) 2945 | # define lzo_intptr_t long 2946 | # define lzo_uintptr_t unsigned long 2947 | # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG 2948 | # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_LONG 2949 | #elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) 2950 | # define lzo_intptr_t lzo_int64l_t 2951 | # define lzo_uintptr_t lzo_uint64l_t 2952 | # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T 2953 | # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_LZO_INT64L_T 2954 | #else 2955 | # error "lzo_intptr_t" 2956 | #endif 2957 | #endif 2958 | #if 1 2959 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) 2960 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) 2961 | #endif 2962 | #if !defined(lzo_word_t) 2963 | #if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) 2964 | #if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) 2965 | # define lzo_word_t lzo_uintptr_t 2966 | # define lzo_sword_t lzo_intptr_t 2967 | # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T 2968 | # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_LZO_INTPTR_T 2969 | #elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) 2970 | # define lzo_word_t unsigned long 2971 | # define lzo_sword_t long 2972 | # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG 2973 | # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_LONG 2974 | #elif (LZO_WORDSIZE == LZO_SIZEOF_INT) 2975 | # define lzo_word_t unsigned int 2976 | # define lzo_sword_t int 2977 | # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT 2978 | # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_INT 2979 | #elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) 2980 | # define lzo_word_t unsigned short 2981 | # define lzo_sword_t short 2982 | # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT 2983 | # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_SHORT 2984 | #elif (LZO_WORDSIZE == 1) 2985 | # define lzo_word_t unsigned char 2986 | # define lzo_sword_t signed char 2987 | # define LZO_SIZEOF_LZO_WORD_T 1 2988 | # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_CHAR 2989 | #elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) 2990 | # define lzo_word_t lzo_uint64l_t 2991 | # define lzo_sword_t lzo_int64l_t 2992 | # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T 2993 | # define LZO_TYPEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T 2994 | #elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) 2995 | #if 0 2996 | typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); 2997 | typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); 2998 | # define lzo_word_t lzo_word_t 2999 | # define lzo_sword_t lzo_sword_t 3000 | # define LZO_SIZEOF_LZO_WORD_T 16 3001 | # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF___MODE_V16QI 3002 | #endif 3003 | #else 3004 | # error "lzo_word_t" 3005 | #endif 3006 | #endif 3007 | #endif 3008 | #if 1 && defined(lzo_word_t) 3009 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) 3010 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) 3011 | #endif 3012 | #if 1 3013 | #define lzo_int8_t signed char 3014 | #define lzo_uint8_t unsigned char 3015 | #define LZO_SIZEOF_LZO_INT8_T 1 3016 | #define LZO_TYPEOF_LZO_INT8_T LZO_TYPEOF_CHAR 3017 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) 3018 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) 3019 | #endif 3020 | #if defined(lzo_int16e_t) 3021 | #define lzo_int16_t lzo_int16e_t 3022 | #define lzo_uint16_t lzo_uint16e_t 3023 | #define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T 3024 | #define LZO_TYPEOF_LZO_INT16_T LZO_TYPEOF_LZO_INT16E_T 3025 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) 3026 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) 3027 | #endif 3028 | #if defined(lzo_int32e_t) 3029 | #define lzo_int32_t lzo_int32e_t 3030 | #define lzo_uint32_t lzo_uint32e_t 3031 | #define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T 3032 | #define LZO_TYPEOF_LZO_INT32_T LZO_TYPEOF_LZO_INT32E_T 3033 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) 3034 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) 3035 | #endif 3036 | #if defined(lzo_int64e_t) 3037 | #define lzo_int64_t lzo_int64e_t 3038 | #define lzo_uint64_t lzo_uint64e_t 3039 | #define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T 3040 | #define LZO_TYPEOF_LZO_INT64_T LZO_TYPEOF_LZO_INT64E_T 3041 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) 3042 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) 3043 | #endif 3044 | #if 1 3045 | #define lzo_int_least32_t lzo_int32l_t 3046 | #define lzo_uint_least32_t lzo_uint32l_t 3047 | #define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T 3048 | #define LZO_TYPEOF_LZO_INT_LEAST32_T LZO_TYPEOF_LZO_INT32L_T 3049 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) 3050 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) 3051 | #endif 3052 | #if defined(lzo_int64l_t) 3053 | #define lzo_int_least64_t lzo_int64l_t 3054 | #define lzo_uint_least64_t lzo_uint64l_t 3055 | #define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T 3056 | #define LZO_TYPEOF_LZO_INT_LEAST64_T LZO_TYPEOF_LZO_INT64L_T 3057 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) 3058 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) 3059 | #endif 3060 | #if 1 3061 | #define lzo_int_fast32_t lzo_int32f_t 3062 | #define lzo_uint_fast32_t lzo_uint32f_t 3063 | #define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T 3064 | #define LZO_TYPEOF_LZO_INT_FAST32_T LZO_TYPEOF_LZO_INT32F_T 3065 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) 3066 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) 3067 | #endif 3068 | #if defined(lzo_int64f_t) 3069 | #define lzo_int_fast64_t lzo_int64f_t 3070 | #define lzo_uint_fast64_t lzo_uint64f_t 3071 | #define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T 3072 | #define LZO_TYPEOF_LZO_INT_FAST64_T LZO_TYPEOF_LZO_INT64F_T 3073 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) 3074 | LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) 3075 | #endif 3076 | #if !defined(LZO_INT16_C) 3077 | # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) 3078 | # define LZO_INT16_C(c) ((c) + 0) 3079 | # define LZO_UINT16_C(c) ((c) + 0U) 3080 | # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) 3081 | # define LZO_INT16_C(c) ((c) + 0L) 3082 | # define LZO_UINT16_C(c) ((c) + 0UL) 3083 | # elif (LZO_SIZEOF_INT >= 2) 3084 | # define LZO_INT16_C(c) (c) 3085 | # define LZO_UINT16_C(c) (c##U) 3086 | # elif (LZO_SIZEOF_LONG >= 2) 3087 | # define LZO_INT16_C(c) (c##L) 3088 | # define LZO_UINT16_C(c) (c##UL) 3089 | # else 3090 | # error "LZO_INT16_C" 3091 | # endif 3092 | #endif 3093 | #if !defined(LZO_INT32_C) 3094 | # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) 3095 | # define LZO_INT32_C(c) ((c) + 0) 3096 | # define LZO_UINT32_C(c) ((c) + 0U) 3097 | # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) 3098 | # define LZO_INT32_C(c) ((c) + 0L) 3099 | # define LZO_UINT32_C(c) ((c) + 0UL) 3100 | # elif (LZO_SIZEOF_INT >= 4) 3101 | # define LZO_INT32_C(c) (c) 3102 | # define LZO_UINT32_C(c) (c##U) 3103 | # elif (LZO_SIZEOF_LONG >= 4) 3104 | # define LZO_INT32_C(c) (c##L) 3105 | # define LZO_UINT32_C(c) (c##UL) 3106 | # elif (LZO_SIZEOF_LONG_LONG >= 4) 3107 | # define LZO_INT32_C(c) (c##LL) 3108 | # define LZO_UINT32_C(c) (c##ULL) 3109 | # else 3110 | # error "LZO_INT32_C" 3111 | # endif 3112 | #endif 3113 | #if !defined(LZO_INT64_C) && defined(lzo_int64l_t) 3114 | # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) 3115 | # define LZO_INT64_C(c) ((c) + 0) 3116 | # define LZO_UINT64_C(c) ((c) + 0U) 3117 | # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) 3118 | # define LZO_INT64_C(c) ((c) + 0L) 3119 | # define LZO_UINT64_C(c) ((c) + 0UL) 3120 | # elif (LZO_SIZEOF_INT >= 8) 3121 | # define LZO_INT64_C(c) (c) 3122 | # define LZO_UINT64_C(c) (c##U) 3123 | # elif (LZO_SIZEOF_LONG >= 8) 3124 | # define LZO_INT64_C(c) (c##L) 3125 | # define LZO_UINT64_C(c) (c##UL) 3126 | # else 3127 | # error "LZO_INT64_C" 3128 | # endif 3129 | #endif 3130 | #endif 3131 | 3132 | #endif /* already included */ 3133 | 3134 | /* vim:set ts=4 sw=4 et: */ 3135 | -------------------------------------------------------------------------------- /src/lzo/minilzo/minilzo.h: -------------------------------------------------------------------------------- 1 | /* minilzo.h -- mini subset of the LZO real-time data compression library 2 | 3 | This file is part of the LZO real-time data compression library. 4 | 5 | Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer 6 | All Rights Reserved. 7 | 8 | The LZO library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of 11 | the License, or (at your option) any later version. 12 | 13 | The LZO library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with the LZO library; see the file COPYING. 20 | If not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | Markus F.X.J. Oberhumer 24 | 25 | http://www.oberhumer.com/opensource/lzo/ 26 | */ 27 | 28 | /* 29 | * NOTE: 30 | * the full LZO package can be found at 31 | * http://www.oberhumer.com/opensource/lzo/ 32 | */ 33 | 34 | 35 | #ifndef __MINILZO_H_INCLUDED 36 | #define __MINILZO_H_INCLUDED 1 37 | 38 | #define MINILZO_VERSION 0x2090 39 | 40 | #if defined(__LZOCONF_H_INCLUDED) 41 | # error "you cannot use both LZO and miniLZO" 42 | #endif 43 | 44 | /* internal Autoconf configuration file - only used when building miniLZO */ 45 | #ifdef MINILZO_HAVE_CONFIG_H 46 | # include 47 | #endif 48 | #include 49 | #include 50 | 51 | #ifndef __LZODEFS_H_INCLUDED 52 | #include "lzodefs.h" 53 | #endif 54 | #undef LZO_HAVE_CONFIG_H 55 | #include "lzoconf.h" 56 | 57 | #if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) 58 | # error "version mismatch in header files" 59 | #endif 60 | 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | 67 | /*********************************************************************** 68 | // 69 | ************************************************************************/ 70 | 71 | /* Memory required for the wrkmem parameter. 72 | * When the required size is 0, you can also pass a NULL pointer. 73 | */ 74 | 75 | #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS 76 | #define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) 77 | #define LZO1X_MEM_DECOMPRESS (0) 78 | 79 | 80 | /* compression */ 81 | LZO_EXTERN(int) 82 | lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, 83 | lzo_bytep dst, lzo_uintp dst_len, 84 | lzo_voidp wrkmem ); 85 | 86 | /* decompression */ 87 | LZO_EXTERN(int) 88 | lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, 89 | lzo_bytep dst, lzo_uintp dst_len, 90 | lzo_voidp wrkmem /* NOT USED */ ); 91 | 92 | /* safe decompression with overrun testing */ 93 | LZO_EXTERN(int) 94 | lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, 95 | lzo_bytep dst, lzo_uintp dst_len, 96 | lzo_voidp wrkmem /* NOT USED */ ); 97 | 98 | 99 | #ifdef __cplusplus 100 | } /* extern "C" */ 101 | #endif 102 | 103 | #endif /* already included */ 104 | 105 | 106 | /* vim:set ts=4 sw=4 et: */ 107 | -------------------------------------------------------------------------------- /src/pcap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pcap.h" 3 | 4 | void pcap_header_init(struct pcap_header * header, unsigned int snaplen) { 5 | header->magic_number = 0xa1b2c3d4; 6 | header->version_major = 0x0002; 7 | header->version_minor = 0x0004; 8 | header->thiszone = 0; 9 | header->sigfigs = 0; 10 | header->snaplen = snaplen; 11 | header->network = 0x00000001; 12 | } 13 | -------------------------------------------------------------------------------- /src/pcap.h: -------------------------------------------------------------------------------- 1 | #ifndef DPDKCAP_PCAP_H 2 | #define DPDKCAP_PCAP_H 3 | 4 | #include 5 | 6 | #define PCAP_SNAPLEN_DEFAULT 65535 7 | 8 | struct __attribute__((__packed__)) pcap_header { 9 | uint32_t magic_number; /* magic number */ 10 | uint16_t version_major; /* major version number */ 11 | uint16_t version_minor; /* minor version number */ 12 | int32_t thiszone; /* GMT to local correction */ 13 | uint32_t sigfigs; /* accuracy of timestamps */ 14 | uint32_t snaplen; /* max length of captured packets, in octets */ 15 | uint32_t network; /* data link type */ 16 | }; 17 | 18 | struct pcap_packet_header { 19 | uint32_t timestamp; 20 | uint32_t microseconds; 21 | uint32_t packet_length; 22 | uint32_t packet_length_wire; 23 | }; 24 | 25 | void pcap_header_init(struct pcap_header * header, unsigned int snaplen); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/statistics.c: -------------------------------------------------------------------------------- 1 | #include "statistics.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "utils.h" 11 | 12 | 13 | #define RTE_LOGTYPE_DPDKCAP RTE_LOGTYPE_USER1 14 | 15 | #define STATS_PERIOD_MS 500 16 | #define ROTATING_CHAR "-\\|/" 17 | 18 | /* 19 | * Prints a set of stats 20 | */ 21 | static int print_stats( 22 | __attribute__((unused))struct rte_timer * timer, 23 | struct stats_data * data) { 24 | static unsigned int nb_stat_update = 0; 25 | static struct rte_eth_stats port_statistics; 26 | 27 | uint64_t total_packets = 0; 28 | uint64_t total_bytes = 0; 29 | uint64_t total_compressedbytes = 0; 30 | unsigned int i, j; 31 | 32 | nb_stat_update ++; 33 | 34 | for (i=0; icores_write_stats_list_size; i++) { 35 | total_packets += data->cores_stats_write_list[i].packets; 36 | total_bytes += data->cores_stats_write_list[i].bytes; 37 | total_compressedbytes += data->cores_stats_write_list[i].compressed_bytes; 38 | } 39 | 40 | printf("\e[1;1H\e[2J"); 41 | printf("=== Packet capture statistics %c ===\n", 42 | ROTATING_CHAR[nb_stat_update%4]); 43 | 44 | printf("-- GLOBAL --\n"); 45 | printf("Entries free on ring: %u\n", rte_ring_free_count(data->ring)); 46 | printf("Total packets written: %lu\n", total_packets); 47 | printf("Total bytes written: %s ", bytes_format(total_bytes)); 48 | printf("compressed to %s\n", bytes_format(total_compressedbytes)); 49 | printf("Compressed/uncompressed size ratio: 1 / %.2f\n", 50 | total_compressedbytes? 51 | (float)total_bytes/(float)total_compressedbytes:0.0f); 52 | 53 | printf("-- PER WRITING CORE --\n"); 54 | for (i=0; icores_write_stats_list_size; i++) { 55 | printf("Writing core %d: %s ", 56 | data->cores_stats_write_list[i].core_id, 57 | data->cores_stats_write_list[i].output_file); 58 | printf("(%s)\n", bytes_format( 59 | data->cores_stats_write_list[i].current_file_compressed_bytes)); 60 | } 61 | 62 | printf("-- PER PORT --\n"); 63 | for (i=0; iport_list_size; i++) { 64 | rte_eth_stats_get(data->port_list[i], &port_statistics); 65 | printf("- PORT %d -\n", data->port_list[i]); 66 | printf("Built-in counters:\n" \ 67 | " RX Successful packets: %lu\n" \ 68 | " RX Successful bytes: %s (avg: %d bytes/pkt)\n" \ 69 | " RX Unsuccessful packets: %lu\n" \ 70 | " RX Missed packets: %lu\n No MBUF: %lu\n", 71 | port_statistics.ipackets, 72 | bytes_format(port_statistics.ibytes), 73 | port_statistics.ipackets? 74 | (int)((float)port_statistics.ibytes/(float)port_statistics.ipackets):0, 75 | port_statistics.ierrors, 76 | port_statistics.imissed, port_statistics.rx_nombuf); 77 | printf("Per queue:\n"); 78 | for (j=0; jqueue_per_port; j++) { 79 | printf(" Queue %d RX: %lu RX-Error: %lu\n", j, 80 | port_statistics.q_ipackets[j], port_statistics.q_errors[j]); 81 | } 82 | printf(" (%d queues hidden)\n", 83 | RTE_ETHDEV_QUEUE_STAT_CNTRS - data->queue_per_port); 84 | } 85 | 86 | printf("===================================\n"); 87 | return 0; 88 | } 89 | 90 | /* 91 | * Handles signals 92 | */ 93 | static bool should_stop = false; 94 | static void signal_handler(int sig) { 95 | RTE_LOG(NOTICE, DPDKCAP, "Caught signal %s on core %u%s\n", 96 | strsignal(sig), rte_lcore_id(), 97 | rte_get_master_lcore()==rte_lcore_id()?" (MASTER CORE)":""); 98 | should_stop = true; 99 | } 100 | 101 | static struct rte_timer stats_timer; 102 | 103 | void start_stats_display(struct stats_data * data) { 104 | signal(SIGINT,signal_handler); 105 | //Initialize timers 106 | rte_timer_subsystem_init(); 107 | //Timer launch 108 | rte_timer_init (&(stats_timer)); 109 | rte_timer_reset(&(stats_timer), 2000000ULL * STATS_PERIOD_MS, PERIODICAL, 110 | rte_lcore_id(), (void*) print_stats, data); 111 | //Wait for ctrl+c 112 | for (;;) { 113 | if (unlikely(should_stop)) { 114 | break; 115 | } 116 | rte_timer_manage(); 117 | } 118 | rte_timer_stop(&(stats_timer)); 119 | signal(SIGINT,SIG_DFL); 120 | } 121 | -------------------------------------------------------------------------------- /src/statistics.h: -------------------------------------------------------------------------------- 1 | #ifndef DPDKCAP_STATISTICS_H 2 | #define DPDKCAP_STATISTICS_H 3 | 4 | #include "core_write.h" 5 | #include "core_capture.h" 6 | 7 | struct stats_data { 8 | struct rte_ring * ring; 9 | struct core_write_stats * cores_stats_write_list; 10 | unsigned int cores_write_stats_list_size; 11 | struct core_capture_stats * cores_stats_capture_list; 12 | unsigned int cores_capture_stats_list_size; 13 | unsigned int * port_list; 14 | unsigned int port_list_size; 15 | unsigned int queue_per_port; 16 | char * log_file; 17 | }; 18 | 19 | 20 | /* 21 | * Starts a non blocking statistics display 22 | */ 23 | void start_stats_display(struct stats_data * data); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/statistics_ncurses.c: -------------------------------------------------------------------------------- 1 | #include "statistics.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "utils.h" 15 | 16 | #define RTE_LOGTYPE_DPDKCAP RTE_LOGTYPE_USER1 17 | 18 | #define GLOBAL_STATS_WINDOW_HEIGHT 10 19 | #define STATS_PERIOD_MS 500 20 | #define ROTATING_CHAR "-\\|/" 21 | 22 | static void wglobal_stats(WINDOW * window, struct stats_data * data) { 23 | if(data->log_file) 24 | wprintw(window,"Writing logs to: %s\n", data->log_file); 25 | else 26 | wprintw(window,"Writing logs to stderr\n"); 27 | wprintw(window,"Entries free on ring: %u\n", 28 | rte_ring_free_count(data->ring)); 29 | } 30 | 31 | static void wcapture_stats(WINDOW * window, struct stats_data * data) { 32 | static uint64_t * last_per_port_packets = NULL; 33 | unsigned int i,j; 34 | static struct rte_eth_stats port_statistics; 35 | 36 | if (!last_per_port_packets) last_per_port_packets = 37 | malloc(sizeof(uint64_t) * data->cores_capture_stats_list_size); 38 | 39 | for (i=0; iport_list_size; i++) { 40 | rte_eth_stats_get(data->port_list[i], &port_statistics); 41 | 42 | wprintw(window,"PORT %d:\n", data->port_list[i]); 43 | wprintw(window," RX Successful bytes: %s (avg: %d bytes/pkt)\n", 44 | bytes_format(port_statistics.ibytes), 45 | port_statistics.ipackets?(int)((float)port_statistics.ibytes/ 46 | (float)port_statistics.ipackets):0); 47 | wprintw(window, " RX Successful packets: %s\n", 48 | ul_format(port_statistics.ipackets)); 49 | wprintw(window, " RX Unsuccessful packets: %s\n", 50 | ul_format(port_statistics.ierrors)); 51 | wprintw(window, " RX Missed packets: %s\n", 52 | ul_format(port_statistics.imissed)); 53 | wprintw(window, " MBUF Allocation failures: %s\n", 54 | ul_format(port_statistics.rx_nombuf)); 55 | 56 | wprintw(window," Per queue:\n"); 57 | for (j=0; jqueue_per_port; j++) { 58 | wprintw(window, " - Queue %2d handled by core %2d:\n", 59 | j, 60 | data->cores_stats_capture_list[i*data->queue_per_port+j].core_id); 61 | wprintw(window, " HW: RX: %s", 62 | ul_format(port_statistics.q_ipackets[j])); 63 | wprintw(window, " RX-Error: %s\n", 64 | ul_format(port_statistics.q_errors[j])); 65 | wprintw(window, " Ring: Enqueued: %s", 66 | ul_format(data->cores_stats_capture_list[i*data->queue_per_port+j] 67 | .packets)); 68 | wprintw(window, " Missed: %s\n", 69 | ul_format(data->cores_stats_capture_list[i*data->queue_per_port+j] 70 | .missed_packets)); 71 | wprintw(window, " Packets/s: %s\n", 72 | ul_format(( 73 | data->cores_stats_capture_list[i*data->queue_per_port+j].packets- 74 | last_per_port_packets[i*data->queue_per_port+j])*1000/STATS_PERIOD_MS)); 75 | 76 | last_per_port_packets[i*data->queue_per_port+j] = 77 | data->cores_stats_capture_list[i*data->queue_per_port+j].packets; 78 | } 79 | wprintw(window, " (%d unused queues hidden)\n", 80 | RTE_ETHDEV_QUEUE_STAT_CNTRS - data->queue_per_port); 81 | wprintw(window, "\n"); 82 | } 83 | } 84 | 85 | static void wwrite_stats(WINDOW * window, struct stats_data * data) { 86 | static uint64_t last_total_packets = 0, 87 | last_total_bytes = 0, 88 | last_total_compressedbytes = 0; 89 | 90 | uint64_t total_packets = 0, 91 | total_bytes = 0, 92 | total_compressedbytes = 0; 93 | uint64_t instant_packets, 94 | instant_bytes, 95 | instant_compressedbytes; 96 | unsigned int i; 97 | 98 | // Calculate aggregated stats from writing cores 99 | for (i=0; icores_write_stats_list_size; i++) { 100 | total_packets += data->cores_stats_write_list[i].packets; 101 | total_bytes += data->cores_stats_write_list[i].bytes; 102 | total_compressedbytes += data->cores_stats_write_list[i].compressed_bytes; 103 | } 104 | 105 | // Calculate instant stats 106 | instant_packets = (total_packets-last_total_packets) 107 | *1000/STATS_PERIOD_MS; 108 | instant_bytes = (total_bytes-last_total_bytes) 109 | *1000/STATS_PERIOD_MS; 110 | instant_compressedbytes = (total_compressedbytes-last_total_compressedbytes) 111 | *1000/STATS_PERIOD_MS; 112 | 113 | last_total_packets = total_packets; 114 | last_total_bytes = total_bytes; 115 | last_total_compressedbytes = total_compressedbytes; 116 | 117 | wprintw(window,"Total packets written: %s\n", 118 | ul_format(total_packets)); 119 | wprintw(window,"Total bytes written: %s", bytes_format(total_bytes)); 120 | wprintw(window," compressed to %s\n", 121 | bytes_format(total_compressedbytes)); 122 | wprintw(window,"Compressed/uncompressed size ratio: 1 / %.2f\n\n", 123 | total_compressedbytes? 124 | (float)total_bytes/(float)total_compressedbytes:0.0f); 125 | 126 | wprintw(window,"Packets written/s: %s/s\n", 127 | ul_format(instant_packets)); 128 | wprintw(window,"Bytes written/s: %s/s", bytes_format(instant_bytes)); 129 | wprintw(window," compressed to %s/s\n", 130 | bytes_format(instant_compressedbytes)); 131 | wprintw(window,"Instant compressed/uncompressed size ratio: 1 / %.2f\n\n", 132 | instant_compressedbytes? 133 | (float)instant_bytes/(float)instant_compressedbytes:0.0f); 134 | 135 | wprintw(window," Per core stats:\n"); 136 | for (i=0; icores_write_stats_list_size; i++) { 137 | wprintw(window, "Writing core %2d: %s ", 138 | data->cores_stats_write_list[i].core_id, 139 | data->cores_stats_write_list[i].output_file); 140 | wprintw(window,"(%s)\n", bytes_format( 141 | data->cores_stats_write_list[i].current_file_compressed_bytes)); 142 | } 143 | } 144 | 145 | /* 146 | * Handles signals 147 | */ 148 | static bool should_stop = false; 149 | static void signal_handler(int sig) { 150 | RTE_LOG(NOTICE, DPDKCAP, "Caught signal %s on core %u%s\n", 151 | strsignal(sig), rte_lcore_id(), 152 | rte_get_master_lcore()==rte_lcore_id()?" (MASTER CORE)":""); 153 | should_stop = true; 154 | } 155 | 156 | 157 | 158 | static WINDOW * border_global, * border_write, * border_capture; 159 | static WINDOW * window_global, * window_write, * window_capture; 160 | 161 | static void mv_windows(void) { 162 | wclear(border_global); 163 | wclear(border_write); 164 | wclear(border_capture); 165 | wclear(window_global); 166 | wclear(window_write); 167 | wclear(window_capture); 168 | 169 | wresize(border_global, GLOBAL_STATS_WINDOW_HEIGHT, COLS/2); 170 | wresize(border_write, (LINES-1)-GLOBAL_STATS_WINDOW_HEIGHT, COLS/2); 171 | wresize(border_capture, LINES-1, COLS/2); 172 | wresize(window_global, GLOBAL_STATS_WINDOW_HEIGHT-2, COLS/2-2); 173 | wresize(window_write, (LINES-1)-GLOBAL_STATS_WINDOW_HEIGHT-2, COLS/2-2); 174 | wresize(window_capture, LINES-1-2, COLS/2-2); 175 | 176 | mvderwin(border_global, 1, 0); 177 | mvderwin(border_write, GLOBAL_STATS_WINDOW_HEIGHT+1, 0); 178 | mvderwin(border_capture,1, COLS/2); 179 | /* mvderwin(window_global, 2, 1); 180 | mvderwin(window_write, GLOBAL_STATS_WINDOW_HEIGHT+2, 1); 181 | mvderwin(window_capture,2, COLS/2+2); 182 | */ 183 | mvderwin(window_global, 1, 1); 184 | mvderwin(window_write, 1, 1); 185 | mvderwin(window_capture,1, 1); 186 | 187 | 188 | } 189 | 190 | static void init_windows(void) { 191 | border_global = subwin(stdscr,0,0,0,0); 192 | border_write = subwin(stdscr,0,0,0,0); 193 | border_capture = subwin(stdscr,0,0,0,0); 194 | 195 | window_global = subwin(border_global,0,0,0,0); 196 | window_write = subwin(border_write,0,0,0,0); 197 | window_capture = subwin(border_capture,0,0,0,0); 198 | 199 | scrollok(window_global,TRUE); 200 | scrollok(window_capture,TRUE); 201 | scrollok(window_write,TRUE); 202 | 203 | mv_windows(); 204 | } 205 | 206 | static int printscreen( 207 | __attribute__((unused))struct rte_timer * timer, 208 | __attribute__((unused))struct stats_data * data) { 209 | static int nb_updates = 0; 210 | 211 | nb_updates++; 212 | 213 | clear(); 214 | /* Move the windows */ 215 | mv_windows(); 216 | 217 | /* Write into the buffers */ 218 | mvprintw(0,0,"%c - Press q to quit",ROTATING_CHAR[nb_updates%4]); 219 | box(border_global,0,0); 220 | mvwprintw(border_global,0,2,"Global stats"); 221 | box(border_write,0,0); 222 | mvwprintw(border_write,0,2,"Write stats"); 223 | box(border_capture,0,0); 224 | mvwprintw(border_capture,0,2,"Capture stats"); 225 | 226 | wglobal_stats(window_global, data); 227 | wwrite_stats(window_write, data); 228 | wcapture_stats(window_capture, data); 229 | 230 | /* Print on screen */ 231 | refresh(); 232 | 233 | return 0; 234 | } 235 | 236 | static struct rte_timer stats_timer; 237 | 238 | void start_stats_display(struct stats_data * data) { 239 | signal(SIGINT,signal_handler); 240 | int ch; 241 | 242 | initscr(); 243 | cbreak(); 244 | noecho(); 245 | keypad(stdscr, TRUE); 246 | curs_set(0); 247 | 248 | //Init windows 249 | init_windows(); 250 | 251 | //Non blocking inputs 252 | timeout(0); 253 | 254 | //Initialize timers 255 | rte_timer_subsystem_init(); 256 | //Timer launch 257 | rte_timer_init (&(stats_timer)); 258 | rte_timer_reset(&(stats_timer), rte_get_timer_hz() * STATS_PERIOD_MS / 1000, 259 | PERIODICAL, rte_lcore_id(), (void*) printscreen, data); 260 | 261 | //Wait for ctrl+c 262 | for (;;) { 263 | if (unlikely(should_stop)) { 264 | break; 265 | } 266 | ch = getch(); 267 | switch(ch) { 268 | case KEY_DOWN: 269 | break; 270 | case KEY_UP: 271 | break; 272 | case 'q': 273 | should_stop = true; 274 | break; 275 | } 276 | 277 | rte_timer_manage(); 278 | } 279 | rte_timer_stop(&(stats_timer)); 280 | 281 | endwin(); 282 | 283 | signal(SIGINT,SIG_DFL); 284 | } 285 | 286 | -------------------------------------------------------------------------------- /src/utils.c: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | #include 3 | #include 4 | #include 5 | 6 | const char * bytes_unit[] = { "B", "KB", "MB", "GB", "TB" }; 7 | const char * nb_unit[] = {"k", "M", "G"}; 8 | char result[50]; 9 | 10 | 11 | char * bytes_format(uint64_t bytes) { 12 | int i; 13 | double converted_bytes = bytes; 14 | for (i = 0; i < 5 && bytes >= 1024; i++, bytes /= 1024) { 15 | converted_bytes = bytes / 1024.0; 16 | } 17 | 18 | sprintf(result, "%.2f %s", converted_bytes, bytes_unit[i]); 19 | return result; 20 | } 21 | 22 | char * ul_format(uint64_t nb) { 23 | int i; 24 | double converted_nb = nb; 25 | for (i = 0; i < 4 && nb >= 1000; i++, nb /= 1000) { 26 | converted_nb = nb / 1000.0; 27 | } 28 | if (i>0) 29 | sprintf(result, "%.2f%s", converted_nb, nb_unit[i-1]); 30 | else 31 | sprintf(result, "%d", (int) converted_nb); 32 | return result; 33 | } 34 | 35 | char * str_replace(const char * src, const char * find, const char * replace) { 36 | int find_len, replace_len, src_left_length; 37 | char * pos = strstr(src,find); 38 | if (pos) { 39 | find_len = strlen(find); 40 | replace_len = strlen(replace); 41 | src_left_length = strlen(pos+find_len)+1; 42 | 43 | memmove(pos+replace_len, pos+find_len, src_left_length); 44 | memmove(pos , replace, replace_len); 45 | } 46 | return pos; 47 | } 48 | -------------------------------------------------------------------------------- /src/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef DPDKCAP_UTILS_H 2 | #define DPDKCAP_UTILS_H 3 | 4 | #include 5 | 6 | char * bytes_format(uint64_t); 7 | char * ul_format(uint64_t); 8 | char * str_replace(const char * src, const char * find, const char * replace); 9 | 10 | #endif 11 | --------------------------------------------------------------------------------