migration
This commit is contained in:
@@ -1,73 +1,73 @@
|
|||||||
module exploit
|
module exploit
|
||||||
(
|
(
|
||||||
// exploit
|
// exploit
|
||||||
input clk_in,
|
input clk_in,
|
||||||
output bang_tx,
|
output bang_tx,
|
||||||
output power_tx,
|
output power_tx,
|
||||||
output [5:0] led
|
output [5:0] led
|
||||||
);
|
);
|
||||||
|
|
||||||
////////// EXPLOIT
|
////////// EXPLOIT
|
||||||
localparam INSTRUCTION_OFFSET = 100;
|
localparam INSTRUCTION_OFFSET = 100;
|
||||||
|
|
||||||
// da official exploit code
|
// da official exploit code
|
||||||
localparam EXPLOIT_BYTES = {16'hFA,16'hEB,16'h11,16'hDD};
|
localparam EXPLOIT_BYTES = {16'hFA,16'hEB,16'h11,16'hDD};
|
||||||
|
|
||||||
localparam EXPLOIT_BYTES_LEN = $bits(EXPLOIT_BYTES)-1; // $bits() seems to work // https://www.linkedin.com/pulse/bits-clog2-size-uses-differences-muhammed-kawser-ahmed
|
localparam EXPLOIT_BYTES_LEN = $bits(EXPLOIT_BYTES)-1; // $bits() seems to work // https://www.linkedin.com/pulse/bits-clog2-size-uses-differences-muhammed-kawser-ahmed
|
||||||
|
|
||||||
localparam LEDS_ON = 0;
|
localparam LEDS_ON = 0;
|
||||||
localparam LEDS_OFF = 6'b111111;
|
localparam LEDS_OFF = 6'b111111;
|
||||||
|
|
||||||
reg [1:0] bang_tx_reg = 0;
|
reg [1:0] bang_tx_reg = 0;
|
||||||
reg [1:0] power_tx_reg = 1;
|
reg [1:0] power_tx_reg = 1;
|
||||||
reg [1:0] led_run = 1;
|
reg [1:0] led_run = 1;
|
||||||
reg [1:0] rst = 0;
|
reg [1:0] rst = 0;
|
||||||
reg [1:0] running = 1;
|
reg [1:0] running = 1;
|
||||||
reg [5:0] ledCounter = 0;
|
reg [5:0] ledCounter = 0;
|
||||||
reg [23:0] instruction_counter = 0;
|
reg [23:0] instruction_counter = 0;
|
||||||
reg [23:0] exploit_tx_count = 0;
|
reg [23:0] exploit_tx_count = 0;
|
||||||
reg [EXPLOIT_BYTES_LEN:0] exploit_bytes_reg = EXPLOIT_BYTES;
|
reg [EXPLOIT_BYTES_LEN:0] exploit_bytes_reg = EXPLOIT_BYTES;
|
||||||
|
|
||||||
always @(posedge clk_in) begin
|
always @(posedge clk_in) begin
|
||||||
if(rst == 1) begin
|
if(rst == 1) begin
|
||||||
running = 1;
|
running = 1;
|
||||||
power_tx_reg = 1;
|
power_tx_reg = 1;
|
||||||
rst = 0;
|
rst = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if(instruction_counter == INSTRUCTION_OFFSET) begin
|
if(instruction_counter == INSTRUCTION_OFFSET) begin
|
||||||
power_tx_reg = 0;
|
power_tx_reg = 0;
|
||||||
rst = 1;
|
rst = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if(running == 1) begin
|
if(running == 1) begin
|
||||||
if(instruction_counter >= INSTRUCTION_OFFSET && instruction_counter <= INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
if(instruction_counter >= INSTRUCTION_OFFSET && instruction_counter <= INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
||||||
bang_tx_reg <= exploit_bytes_reg[exploit_tx_count];
|
bang_tx_reg <= exploit_bytes_reg[exploit_tx_count];
|
||||||
exploit_tx_count <= exploit_tx_count + 1;
|
exploit_tx_count <= exploit_tx_count + 1;
|
||||||
led_run <= 1;
|
led_run <= 1;
|
||||||
end else begin
|
end else begin
|
||||||
led_run <= 0;
|
led_run <= 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if(led_run == 1) begin
|
if(led_run == 1) begin
|
||||||
ledCounter <= ledCounter + 1;
|
ledCounter <= ledCounter + 1;
|
||||||
if(ledCounter == LEDS_OFF) begin
|
if(ledCounter == LEDS_OFF) begin
|
||||||
ledCounter <= LEDS_ON;
|
ledCounter <= LEDS_ON;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if(instruction_counter == INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
if(instruction_counter == INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
||||||
ledCounter <= LEDS_ON;
|
ledCounter <= LEDS_ON;
|
||||||
rst = 1;
|
rst = 1;
|
||||||
running = 0;
|
running = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
instruction_counter <= instruction_counter + 1;
|
instruction_counter <= instruction_counter + 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assign led = ledCounter;
|
assign led = ledCounter;
|
||||||
assign bang_tx = bang_tx_reg;
|
assign bang_tx = bang_tx_reg;
|
||||||
assign power_tx = power_tx_reg;
|
assign power_tx = power_tx_reg;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
@@ -1,217 +1,217 @@
|
|||||||
module exploit
|
module exploit
|
||||||
#(
|
#(
|
||||||
parameter DELAY_FRAMES = 234 // 27,000,000 (27Mhz) / 115200 Baud rate
|
parameter DELAY_FRAMES = 234 // 27,000,000 (27Mhz) / 115200 Baud rate
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
// exploit
|
// exploit
|
||||||
input clk_in,
|
input clk_in,
|
||||||
output power_tx,
|
output power_tx,
|
||||||
output [5:0] led,
|
output [5:0] led,
|
||||||
|
|
||||||
// uart
|
// uart
|
||||||
input clk,
|
input clk,
|
||||||
input btn1,
|
input btn1,
|
||||||
input uart_rx,
|
input uart_rx,
|
||||||
output uart_tx
|
output uart_tx
|
||||||
);
|
);
|
||||||
|
|
||||||
////////// EXPLOIT
|
////////// EXPLOIT
|
||||||
localparam INSTRUCTION_OFFSET = 100;
|
localparam INSTRUCTION_OFFSET = 100;
|
||||||
|
|
||||||
// da official exploit code
|
// da official exploit code
|
||||||
localparam EXPLOIT_BYTES = {8'h5D,8'h5D,8'h5D,8'h5D};
|
localparam EXPLOIT_BYTES = {8'h5D,8'h5D,8'h5D,8'h5D};
|
||||||
|
|
||||||
|
|
||||||
//// glitch logic
|
//// glitch logic
|
||||||
|
|
||||||
localparam EXPLOIT_BYTES_LEN = $bits(EXPLOIT_BYTES)-1; // $bits() seems to work // https://www.linkedin.com/pulse/bits-clog2-size-uses-differences-muhammed-kawser-ahmed
|
localparam EXPLOIT_BYTES_LEN = $bits(EXPLOIT_BYTES)-1; // $bits() seems to work // https://www.linkedin.com/pulse/bits-clog2-size-uses-differences-muhammed-kawser-ahmed
|
||||||
localparam LEDS_ON = 0;
|
localparam LEDS_ON = 0;
|
||||||
localparam LEDS_OFF = 6'b111111;
|
localparam LEDS_OFF = 6'b111111;
|
||||||
|
|
||||||
reg [1:0] power_tx_reg = 1;
|
reg [1:0] power_tx_reg = 1;
|
||||||
reg [1:0] led_run = 1;
|
reg [1:0] led_run = 1;
|
||||||
reg [1:0] rst = 0;
|
reg [1:0] rst = 0;
|
||||||
reg [1:0] running = 1;
|
reg [1:0] running = 1;
|
||||||
reg [5:0] ledCounter = 0;
|
reg [5:0] ledCounter = 0;
|
||||||
reg [23:0] instruction_counter = 0;
|
reg [23:0] instruction_counter = 0;
|
||||||
reg [23:0] exploit_tx_count = 0;
|
reg [23:0] exploit_tx_count = 0;
|
||||||
reg [EXPLOIT_BYTES_LEN:0] exploit_bytes_reg = EXPLOIT_BYTES;
|
reg [EXPLOIT_BYTES_LEN:0] exploit_bytes_reg = EXPLOIT_BYTES;
|
||||||
|
|
||||||
always @(posedge clk_in) begin
|
always @(posedge clk_in) begin
|
||||||
if(rst == 1) begin
|
if(rst == 1) begin
|
||||||
running = 1;
|
running = 1;
|
||||||
power_tx_reg = 1;
|
power_tx_reg = 1;
|
||||||
rst = 0;
|
rst = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if(instruction_counter == INSTRUCTION_OFFSET) begin
|
if(instruction_counter == INSTRUCTION_OFFSET) begin
|
||||||
power_tx_reg = 0;
|
power_tx_reg = 0;
|
||||||
rst = 1;
|
rst = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if(running == 1) begin
|
if(running == 1) begin
|
||||||
if(instruction_counter >= INSTRUCTION_OFFSET && instruction_counter <= INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
if(instruction_counter >= INSTRUCTION_OFFSET && instruction_counter <= INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
||||||
led_run <= 1;
|
led_run <= 1;
|
||||||
end else begin
|
end else begin
|
||||||
led_run <= 0;
|
led_run <= 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if(led_run == 1) begin
|
if(led_run == 1) begin
|
||||||
ledCounter <= ledCounter + 1;
|
ledCounter <= ledCounter + 1;
|
||||||
if(ledCounter == LEDS_OFF) begin
|
if(ledCounter == LEDS_OFF) begin
|
||||||
ledCounter <= LEDS_ON;
|
ledCounter <= LEDS_ON;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if(instruction_counter == INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
if(instruction_counter == INSTRUCTION_OFFSET+EXPLOIT_BYTES_LEN) begin
|
||||||
ledCounter <= LEDS_ON;
|
ledCounter <= LEDS_ON;
|
||||||
rst = 1;
|
rst = 1;
|
||||||
running = 0;
|
running = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
instruction_counter <= instruction_counter + 1;
|
instruction_counter <= instruction_counter + 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
//// uart rx
|
//// uart rx
|
||||||
// uart shit ganked from https://raw.githubusercontent.com/lushaylabs/tangnano9k-series-examples/
|
// uart shit ganked from https://raw.githubusercontent.com/lushaylabs/tangnano9k-series-examples/
|
||||||
// of https://learn.lushaylabs.com
|
// of https://learn.lushaylabs.com
|
||||||
|
|
||||||
localparam HALF_DELAY_WAIT = (DELAY_FRAMES / 2);
|
localparam HALF_DELAY_WAIT = (DELAY_FRAMES / 2);
|
||||||
|
|
||||||
reg [3:0] rxState = 0;
|
reg [3:0] rxState = 0;
|
||||||
reg [12:0] rxCounter = 0;
|
reg [12:0] rxCounter = 0;
|
||||||
reg [7:0] dataIn = 0;
|
reg [7:0] dataIn = 0;
|
||||||
reg [2:0] rxBitNumber = 0;
|
reg [2:0] rxBitNumber = 0;
|
||||||
reg byteReady = 0;
|
reg byteReady = 0;
|
||||||
|
|
||||||
localparam RX_STATE_IDLE = 0;
|
localparam RX_STATE_IDLE = 0;
|
||||||
localparam RX_STATE_START_BIT = 1;
|
localparam RX_STATE_START_BIT = 1;
|
||||||
localparam RX_STATE_READ_WAIT = 2;
|
localparam RX_STATE_READ_WAIT = 2;
|
||||||
localparam RX_STATE_READ = 3;
|
localparam RX_STATE_READ = 3;
|
||||||
localparam RX_STATE_STOP_BIT = 5;
|
localparam RX_STATE_STOP_BIT = 5;
|
||||||
|
|
||||||
always @(posedge clk) begin
|
always @(posedge clk) begin
|
||||||
case (rxState)
|
case (rxState)
|
||||||
RX_STATE_IDLE: begin
|
RX_STATE_IDLE: begin
|
||||||
if (uart_rx == 0) begin
|
if (uart_rx == 0) begin
|
||||||
rxState <= RX_STATE_START_BIT;
|
rxState <= RX_STATE_START_BIT;
|
||||||
rxCounter <= 1;
|
rxCounter <= 1;
|
||||||
rxBitNumber <= 0;
|
rxBitNumber <= 0;
|
||||||
byteReady <= 0;
|
byteReady <= 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RX_STATE_START_BIT: begin
|
RX_STATE_START_BIT: begin
|
||||||
if (rxCounter == HALF_DELAY_WAIT) begin
|
if (rxCounter == HALF_DELAY_WAIT) begin
|
||||||
rxState <= RX_STATE_READ_WAIT;
|
rxState <= RX_STATE_READ_WAIT;
|
||||||
rxCounter <= 1;
|
rxCounter <= 1;
|
||||||
end else
|
end else
|
||||||
rxCounter <= rxCounter + 1;
|
rxCounter <= rxCounter + 1;
|
||||||
end
|
end
|
||||||
RX_STATE_READ_WAIT: begin
|
RX_STATE_READ_WAIT: begin
|
||||||
rxCounter <= rxCounter + 1;
|
rxCounter <= rxCounter + 1;
|
||||||
if ((rxCounter + 1) == DELAY_FRAMES) begin
|
if ((rxCounter + 1) == DELAY_FRAMES) begin
|
||||||
rxState <= RX_STATE_READ;
|
rxState <= RX_STATE_READ;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RX_STATE_READ: begin
|
RX_STATE_READ: begin
|
||||||
rxCounter <= 1;
|
rxCounter <= 1;
|
||||||
dataIn <= {uart_rx, dataIn[7:1]};
|
dataIn <= {uart_rx, dataIn[7:1]};
|
||||||
rxBitNumber <= rxBitNumber + 1;
|
rxBitNumber <= rxBitNumber + 1;
|
||||||
if (rxBitNumber == 3'b111)
|
if (rxBitNumber == 3'b111)
|
||||||
rxState <= RX_STATE_STOP_BIT;
|
rxState <= RX_STATE_STOP_BIT;
|
||||||
else
|
else
|
||||||
rxState <= RX_STATE_READ_WAIT;
|
rxState <= RX_STATE_READ_WAIT;
|
||||||
end
|
end
|
||||||
RX_STATE_STOP_BIT: begin
|
RX_STATE_STOP_BIT: begin
|
||||||
rxCounter <= rxCounter + 1;
|
rxCounter <= rxCounter + 1;
|
||||||
if ((rxCounter + 1) == DELAY_FRAMES) begin
|
if ((rxCounter + 1) == DELAY_FRAMES) begin
|
||||||
rxState <= RX_STATE_IDLE;
|
rxState <= RX_STATE_IDLE;
|
||||||
rxCounter <= 0;
|
rxCounter <= 0;
|
||||||
byteReady <= 1;
|
byteReady <= 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
//// uart tx
|
//// uart tx
|
||||||
|
|
||||||
reg [3:0] txState = 0;
|
reg [3:0] txState = 0;
|
||||||
reg [24:0] txCounter = 0;
|
reg [24:0] txCounter = 0;
|
||||||
reg [1:0] txPinRegister = 1;
|
reg [1:0] txPinRegister = 1;
|
||||||
reg [2:0] txBitNumber = 0;
|
reg [2:0] txBitNumber = 0;
|
||||||
reg [3:0] txByteCounter = 0;
|
reg [3:0] txByteCounter = 0;
|
||||||
|
|
||||||
localparam MEMORY_LENGTH = 5;
|
localparam MEMORY_LENGTH = 5;
|
||||||
|
|
||||||
localparam TX_STATE_IDLE = 0;
|
localparam TX_STATE_IDLE = 0;
|
||||||
localparam TX_STATE_START_BIT = 1;
|
localparam TX_STATE_START_BIT = 1;
|
||||||
localparam TX_STATE_WRITE = 2;
|
localparam TX_STATE_WRITE = 2;
|
||||||
localparam TX_STATE_STOP_BIT = 3;
|
localparam TX_STATE_STOP_BIT = 3;
|
||||||
localparam TX_STATE_DEBOUNCE = 4;
|
localparam TX_STATE_DEBOUNCE = 4;
|
||||||
|
|
||||||
always @(posedge clk) begin
|
always @(posedge clk) begin
|
||||||
case (txState)
|
case (txState)
|
||||||
TX_STATE_IDLE: begin
|
TX_STATE_IDLE: begin
|
||||||
if (btn1 == 0) begin
|
if (btn1 == 0) begin
|
||||||
txState <= TX_STATE_START_BIT;
|
txState <= TX_STATE_START_BIT;
|
||||||
txCounter <= 0;
|
txCounter <= 0;
|
||||||
txByteCounter <= 0;
|
txByteCounter <= 0;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
txPinRegister <= 1;
|
txPinRegister <= 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
TX_STATE_START_BIT: begin
|
TX_STATE_START_BIT: begin
|
||||||
txPinRegister <= 0;
|
txPinRegister <= 0;
|
||||||
if ((txCounter + 1) == DELAY_FRAMES) begin
|
if ((txCounter + 1) == DELAY_FRAMES) begin
|
||||||
txState <= TX_STATE_WRITE;
|
txState <= TX_STATE_WRITE;
|
||||||
txBitNumber <= 0;
|
txBitNumber <= 0;
|
||||||
txCounter <= 0;
|
txCounter <= 0;
|
||||||
end else
|
end else
|
||||||
txCounter <= txCounter + 1;
|
txCounter <= txCounter + 1;
|
||||||
end
|
end
|
||||||
TX_STATE_WRITE: begin
|
TX_STATE_WRITE: begin
|
||||||
txPinRegister <= exploit_bytes_reg[txBitNumber];
|
txPinRegister <= exploit_bytes_reg[txBitNumber];
|
||||||
if ((txCounter + 1) == DELAY_FRAMES) begin
|
if ((txCounter + 1) == DELAY_FRAMES) begin
|
||||||
if (txBitNumber == 7) begin
|
if (txBitNumber == 7) begin
|
||||||
txState <= TX_STATE_STOP_BIT;
|
txState <= TX_STATE_STOP_BIT;
|
||||||
end else begin
|
end else begin
|
||||||
txState <= TX_STATE_WRITE;
|
txState <= TX_STATE_WRITE;
|
||||||
txBitNumber <= txBitNumber + 1;
|
txBitNumber <= txBitNumber + 1;
|
||||||
end
|
end
|
||||||
txCounter <= 0;
|
txCounter <= 0;
|
||||||
end else
|
end else
|
||||||
txCounter <= txCounter + 1;
|
txCounter <= txCounter + 1;
|
||||||
end
|
end
|
||||||
TX_STATE_STOP_BIT: begin
|
TX_STATE_STOP_BIT: begin
|
||||||
txPinRegister <= 1;
|
txPinRegister <= 1;
|
||||||
if ((txCounter + 1) == DELAY_FRAMES) begin
|
if ((txCounter + 1) == DELAY_FRAMES) begin
|
||||||
if (txByteCounter == MEMORY_LENGTH - 1) begin
|
if (txByteCounter == MEMORY_LENGTH - 1) begin
|
||||||
txState <= TX_STATE_DEBOUNCE;
|
txState <= TX_STATE_DEBOUNCE;
|
||||||
end else begin
|
end else begin
|
||||||
txByteCounter <= txByteCounter + 1;
|
txByteCounter <= txByteCounter + 1;
|
||||||
txState <= TX_STATE_START_BIT;
|
txState <= TX_STATE_START_BIT;
|
||||||
end
|
end
|
||||||
txCounter <= 0;
|
txCounter <= 0;
|
||||||
end else
|
end else
|
||||||
txCounter <= txCounter + 1;
|
txCounter <= txCounter + 1;
|
||||||
end
|
end
|
||||||
TX_STATE_DEBOUNCE: begin
|
TX_STATE_DEBOUNCE: begin
|
||||||
if (txCounter == 23'b111111111111111111) begin
|
if (txCounter == 23'b111111111111111111) begin
|
||||||
if (btn1 == 1)
|
if (btn1 == 1)
|
||||||
txState <= TX_STATE_IDLE;
|
txState <= TX_STATE_IDLE;
|
||||||
end else
|
end else
|
||||||
txCounter <= txCounter + 1;
|
txCounter <= txCounter + 1;
|
||||||
end
|
end
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
// assigns to output
|
// assigns to output
|
||||||
assign led = ledCounter;
|
assign led = ledCounter;
|
||||||
assign power_tx = power_tx_reg;
|
assign power_tx = power_tx_reg;
|
||||||
assign uart_tx = txPinRegister;
|
assign uart_tx = txPinRegister;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
Made for the [Tang Nano 9K FPGA](https://www.aliexpress.us/item/3256807026232976.html?channel=twinner)
|
Made for the [Tang Nano 9K FPGA](https://www.aliexpress.us/item/3256807026232976.html?channel=twinner)
|
||||||
Build using [Lushay Code](https://learn.lushaylabs.com/vscode-extension/) for VS Code
|
Build using [Lushay Code](https://learn.lushaylabs.com/vscode-extension/) for VS Code
|
||||||
|
|
||||||
Testing using the two versions
|
Testing using the two versions
|
||||||
[Bit-bang version](ESP32-S3_Exploit_BitBang/)
|
[Bit-bang version](ESP32-S3_Exploit_BitBang/)
|
||||||
[UART version](ESP32-S3_Exploit_UART/)
|
[UART version](ESP32-S3_Exploit_UART/)
|
||||||
+77
-77
@@ -1,78 +1,78 @@
|
|||||||
# name start end length R W X
|
# name start end length R W X
|
||||||
segment_0 3fcd7000 3fcd75b3 0x5b4 true true false
|
segment_0 3fcd7000 3fcd75b3 0x5b4 true true false
|
||||||
.static_dram_start 3fcd7e00 3fcd7e03 0x4 true true false
|
.static_dram_start 3fcd7e00 3fcd7e03 0x4 true true false
|
||||||
.bss_shared_bufs 3fcd7e04 3fce9703 0x11900 true true false
|
.bss_shared_bufs 3fcd7e04 3fce9703 0x11900 true true false
|
||||||
.stack_pro 3fce9704 3fceb70f 0x200c true true false
|
.stack_pro 3fce9704 3fceb70f 0x200c true true false
|
||||||
.stack_app 3fceb710 3fced70f 0x2000 true true false
|
.stack_app 3fceb710 3fced70f 0x2000 true true false
|
||||||
.bss_ets 3fced710 3fcedf1b 0x80c true true false
|
.bss_ets 3fced710 3fcedf1b 0x80c true true false
|
||||||
.bss_spi_slave 3fcedf1c 3fcedf2f 0x14 true true false
|
.bss_spi_slave 3fcedf1c 3fcedf2f 0x14 true true false
|
||||||
.bss_hal 3fcedf30 3fcedf5f 0x30 true true false
|
.bss_hal 3fcedf30 3fcedf5f 0x30 true true false
|
||||||
.bss_xtos 3fcee380 3fceee33 0xab4 true true false
|
.bss_xtos 3fcee380 3fceee33 0xab4 true true false
|
||||||
.bss_usbdev 3fceeeb4 3fcef12f 0x27c true true false
|
.bss_usbdev 3fceeeb4 3fcef12f 0x27c true true false
|
||||||
.bss_uart 3fcef134 3fcef173 0x40 true true false
|
.bss_uart 3fcef134 3fcef173 0x40 true true false
|
||||||
.bss_btdm 3fcef180 3fcef1a3 0x24 true true false
|
.bss_btdm 3fcef180 3fcef1a3 0x24 true true false
|
||||||
.bss_pp_rom 3fcef308 3fcef3d3 0xcc true true false
|
.bss_pp_rom 3fcef308 3fcef3d3 0xcc true true false
|
||||||
.bss_spi_flash 3fcef6c0 3fcef713 0x54 true true false
|
.bss_spi_flash 3fcef6c0 3fcef713 0x54 true true false
|
||||||
.bss_cache 3fcef71c 3fcef73b 0x20 true true false
|
.bss_cache 3fcef71c 3fcef73b 0x20 true true false
|
||||||
.bss_opi_flash 3fcef73c 3fcef743 0x8 true true false
|
.bss_opi_flash 3fcef73c 3fcef743 0x8 true true false
|
||||||
.bss_ets_printf 3fcef744 3fcef757 0x14 true true false
|
.bss_ets_printf 3fcef744 3fcef757 0x14 true true false
|
||||||
.bss_ets_rtc 3fcef75c 3fcef75f 0x4 true true false
|
.bss_ets_rtc 3fcef75c 3fcef75f 0x4 true true false
|
||||||
.bss_ets_apb_backup 3fcef760 3fcef767 0x8 true true false
|
.bss_ets_apb_backup 3fcef760 3fcef767 0x8 true true false
|
||||||
.bss_newlib 3fcef768 3fcef76f 0x8 true true false
|
.bss_newlib 3fcef768 3fcef76f 0x8 true true false
|
||||||
.rodata 3ff18c00 3ff1eb3b 0x5f3c true false false
|
.rodata 3ff18c00 3ff1eb3b 0x5f3c true false false
|
||||||
.WindowVectors.text 40000000 4000016f 0x170 true false true
|
.WindowVectors.text 40000000 4000016f 0x170 true false true
|
||||||
.Level2InterruptVector.text 40000180 40000185 0x6 true false true
|
.Level2InterruptVector.text 40000180 40000185 0x6 true false true
|
||||||
.Level3InterruptVector.text 400001c0 400001c5 0x6 true false true
|
.Level3InterruptVector.text 400001c0 400001c5 0x6 true false true
|
||||||
.Level4InterruptVector.text 40000200 40000205 0x6 true false true
|
.Level4InterruptVector.text 40000200 40000205 0x6 true false true
|
||||||
.Level5InterruptVector.text 40000240 40000245 0x6 true false true
|
.Level5InterruptVector.text 40000240 40000245 0x6 true false true
|
||||||
.DebugExceptionVector.text 40000280 4000028a 0xb true false true
|
.DebugExceptionVector.text 40000280 4000028a 0xb true false true
|
||||||
.NMIExceptionVector.text 400002c0 400002c2 0x3 true false true
|
.NMIExceptionVector.text 400002c0 400002c2 0x3 true false true
|
||||||
.KernelExceptionVector.text 40000300 40000305 0x6 true false true
|
.KernelExceptionVector.text 40000300 40000305 0x6 true false true
|
||||||
.UserExceptionVector.text 40000340 40000364 0x25 true false true
|
.UserExceptionVector.text 40000340 40000364 0x25 true false true
|
||||||
.DoubleExceptionVector.text 400003c0 400003c5 0x6 true false true
|
.DoubleExceptionVector.text 400003c0 400003c5 0x6 true false true
|
||||||
.ResetVector.text 40000400 4000056b 0x16c true false true
|
.ResetVector.text 40000400 4000056b 0x16c true false true
|
||||||
.fixed.test 4000056c 40006433 0x5ec8 true false true
|
.fixed.test 4000056c 40006433 0x5ec8 true false true
|
||||||
.bt_text 40006434 40034af1 0x2e6be true false true
|
.bt_text 40006434 40034af1 0x2e6be true false true
|
||||||
.text 40034af4 400577a7 0x22cb4 true false true
|
.text 40034af4 400577a7 0x22cb4 true false true
|
||||||
EXTERNAL 40058000 40058427 0x428 true true false
|
EXTERNAL 40058000 40058427 0x428 true true false
|
||||||
.bss.interface.bluetooth .bss.interface.bluetooth::3fcefa14 .bss.interface.bluetooth::3fceffab 0x598 false false false
|
.bss.interface.bluetooth .bss.interface.bluetooth::3fcefa14 .bss.interface.bluetooth::3fceffab 0x598 false false false
|
||||||
.bss.interface.cache .bss.interface.cache::3fceffc8 .bss.interface.cache::3fceffcf 0x8 false false false
|
.bss.interface.cache .bss.interface.cache::3fceffc8 .bss.interface.cache::3fceffcf 0x8 false false false
|
||||||
.bss.interface.esp_flash .bss.interface.esp_flash::3fceffdc .bss.interface.esp_flash::3fceffdf 0x4 false false false
|
.bss.interface.esp_flash .bss.interface.esp_flash::3fceffdc .bss.interface.esp_flash::3fceffdf 0x4 false false false
|
||||||
.bss.interface.newlib .bss.interface.newlib::3fceffd0 .bss.interface.newlib::3fceffd7 0x8 false false false
|
.bss.interface.newlib .bss.interface.newlib::3fceffd0 .bss.interface.newlib::3fceffd7 0x8 false false false
|
||||||
.bss.interface.opi_flash .bss.interface.opi_flash::3fcefff4 .bss.interface.opi_flash::3fcefff7 0x4 false false false
|
.bss.interface.opi_flash .bss.interface.opi_flash::3fcefff4 .bss.interface.opi_flash::3fcefff7 0x4 false false false
|
||||||
.bss.interface.rom_coexist .bss.interface.rom_coexist::3fcef820 .bss.interface.rom_coexist::3fcef837 0x18 false false false
|
.bss.interface.rom_coexist .bss.interface.rom_coexist::3fcef820 .bss.interface.rom_coexist::3fcef837 0x18 false false false
|
||||||
.bss.interface.rom_net80211 .bss.interface.rom_net80211::3fcef838 .bss.interface.rom_net80211::3fcef85b 0x24 false false false
|
.bss.interface.rom_net80211 .bss.interface.rom_net80211::3fcef838 .bss.interface.rom_net80211::3fcef85b 0x24 false false false
|
||||||
.bss.interface.rom_phy .bss.interface.rom_phy::3fcef81c .bss.interface.rom_phy::3fcef81f 0x4 false false false
|
.bss.interface.rom_phy .bss.interface.rom_phy::3fcef81c .bss.interface.rom_phy::3fcef81f 0x4 false false false
|
||||||
.bss.interface.rom_pp .bss.interface.rom_pp::3fcef85c .bss.interface.rom_pp::3fcef957 0xfc false false false
|
.bss.interface.rom_pp .bss.interface.rom_pp::3fcef85c .bss.interface.rom_pp::3fcef957 0xfc false false false
|
||||||
.bss.interface.spiflash_legacy .bss.interface.spiflash_legacy::3fceffec .bss.interface.spiflash_legacy::3fceffef 0x4 false false false
|
.bss.interface.spiflash_legacy .bss.interface.spiflash_legacy::3fceffec .bss.interface.spiflash_legacy::3fceffef 0x4 false false false
|
||||||
.bss.interface.usb_module .bss.interface.usb_module::3fceffac .bss.interface.usb_module::3fceffb7 0xc false false false
|
.bss.interface.usb_module .bss.interface.usb_module::3fceffac .bss.interface.usb_module::3fceffb7 0xc false false false
|
||||||
.bss.interface.usb_uart .bss.interface.usb_uart::3fceffb8 .bss.interface.usb_uart::3fceffbf 0x8 false false false
|
.bss.interface.usb_uart .bss.interface.usb_uart::3fceffb8 .bss.interface.usb_uart::3fceffbf 0x8 false false false
|
||||||
.comment .comment::00000000 .comment::00000067 0x68 false false false
|
.comment .comment::00000000 .comment::00000067 0x68 false false false
|
||||||
.data.interface.bluetooth .data.interface.bluetooth::3fcef958 .data.interface.bluetooth::3fcefa13 0xbc false false false
|
.data.interface.bluetooth .data.interface.bluetooth::3fcef958 .data.interface.bluetooth::3fcefa13 0xbc false false false
|
||||||
.data.interface.cache .data.interface.cache::3fceffc4 .data.interface.cache::3fceffc7 0x4 false false false
|
.data.interface.cache .data.interface.cache::3fceffc4 .data.interface.cache::3fceffc7 0x4 false false false
|
||||||
.data.interface.common .data.interface.common::3fcefffc .data.interface.common::3fceffff 0x4 false false false
|
.data.interface.common .data.interface.common::3fcefffc .data.interface.common::3fceffff 0x4 false false false
|
||||||
.data.interface.ecc .data.interface.ecc::3fceffc0 .data.interface.ecc::3fceffc3 0x4 false false false
|
.data.interface.ecc .data.interface.ecc::3fceffc0 .data.interface.ecc::3fceffc3 0x4 false false false
|
||||||
.data.interface.esp-dsp .data.interface.esp-dsp::3fcefff8 .data.interface.esp-dsp::3fcefffb 0x4 false false false
|
.data.interface.esp-dsp .data.interface.esp-dsp::3fcefff8 .data.interface.esp-dsp::3fcefffb 0x4 false false false
|
||||||
.data.interface.esp_flash .data.interface.esp_flash::3fceffd8 .data.interface.esp_flash::3fceffdb 0x4 false false false
|
.data.interface.esp_flash .data.interface.esp_flash::3fceffd8 .data.interface.esp_flash::3fceffdb 0x4 false false false
|
||||||
.data.interface.opi_flash .data.interface.opi_flash::3fcefff0 .data.interface.opi_flash::3fcefff3 0x4 false false false
|
.data.interface.opi_flash .data.interface.opi_flash::3fcefff0 .data.interface.opi_flash::3fcefff3 0x4 false false false
|
||||||
.data.interface.spi_flash_chips .data.interface.spi_flash_chips::3fceffe0 .data.interface.spi_flash_chips::3fceffe3 0x4 false false false
|
.data.interface.spi_flash_chips .data.interface.spi_flash_chips::3fceffe0 .data.interface.spi_flash_chips::3fceffe3 0x4 false false false
|
||||||
.data.interface.spiflash_legacy .data.interface.spiflash_legacy::3fceffe4 .data.interface.spiflash_legacy::3fceffeb 0x8 false false false
|
.data.interface.spiflash_legacy .data.interface.spiflash_legacy::3fceffe4 .data.interface.spiflash_legacy::3fceffeb 0x8 false false false
|
||||||
.data_btdm .data_btdm::3fcef174 .data_btdm::3fcef17f 0xc false false false
|
.data_btdm .data_btdm::3fcef174 .data_btdm::3fcef17f 0xc false false false
|
||||||
.data_cache .data_cache::3fcef714 .data_cache::3fcef71b 0x8 false false false
|
.data_cache .data_cache::3fcef714 .data_cache::3fcef71b 0x8 false false false
|
||||||
.data_coexist_rom .data_coexist_rom::3fcef1a4 .data_coexist_rom::3fcef1a7 0x4 false false false
|
.data_coexist_rom .data_coexist_rom::3fcef1a4 .data_coexist_rom::3fcef1a7 0x4 false false false
|
||||||
.data_ets_delay .data_ets_delay::3fcef758 .data_ets_delay::3fcef75b 0x4 false false false
|
.data_ets_delay .data_ets_delay::3fcef758 .data_ets_delay::3fcef75b 0x4 false false false
|
||||||
.data_net80211_rom .data_net80211_rom::3fcef1a8 .data_net80211_rom::3fcef1ab 0x4 false false false
|
.data_net80211_rom .data_net80211_rom::3fcef1a8 .data_net80211_rom::3fcef1ab 0x4 false false false
|
||||||
.data_phyrom .data_phyrom::3fcef3d4 .data_phyrom::3fcef66b 0x298 false false false
|
.data_phyrom .data_phyrom::3fcef3d4 .data_phyrom::3fcef66b 0x298 false false false
|
||||||
.data_pp_rom .data_pp_rom::3fcef1ac .data_pp_rom::3fcef307 0x15c false false false
|
.data_pp_rom .data_pp_rom::3fcef1ac .data_pp_rom::3fcef307 0x15c false false false
|
||||||
.data_spi_flash .data_spi_flash::3fcef66c .data_spi_flash::3fcef6bf 0x54 false false false
|
.data_spi_flash .data_spi_flash::3fcef66c .data_spi_flash::3fcef6bf 0x54 false false false
|
||||||
.data_uart .data_uart::3fcef130 .data_uart::3fcef133 0x4 false false false
|
.data_uart .data_uart::3fcef130 .data_uart::3fcef133 0x4 false false false
|
||||||
.data_usbdev .data_usbdev::3fceee34 .data_usbdev::3fceeeb3 0x80 false false false
|
.data_usbdev .data_usbdev::3fceee34 .data_usbdev::3fceeeb3 0x80 false false false
|
||||||
.data_xtos .data_xtos::3fcedf60 .data_xtos::3fcee377 0x418 false false false
|
.data_xtos .data_xtos::3fcedf60 .data_xtos::3fcee377 0x418 false false false
|
||||||
.rodata.interface .rodata.interface::3ff1ee50 .rodata.interface::3ff1ffff 0x11b0 false false false
|
.rodata.interface .rodata.interface::3ff1ee50 .rodata.interface::3ff1ffff 0x11b0 false false false
|
||||||
.shstrtab .shstrtab::00000000 .shstrtab::000006a8 0x6a9 false false false
|
.shstrtab .shstrtab::00000000 .shstrtab::000006a8 0x6a9 false false false
|
||||||
.strtab .strtab::00000000 .strtab::0001515f 0x15160 false false false
|
.strtab .strtab::00000000 .strtab::0001515f 0x15160 false false false
|
||||||
.symtab .symtab::00000000 .symtab::0001cebf 0x1cec0 false false false
|
.symtab .symtab::00000000 .symtab::0001cebf 0x1cec0 false false false
|
||||||
.xt.lit .xt.lit::00000000 .xt.lit::00001a17 0x1a18 false false false
|
.xt.lit .xt.lit::00000000 .xt.lit::00001a17 0x1a18 false false false
|
||||||
.xt.prop .xt.prop::00000000 .xt.prop::0004edbb 0x4edbc false false false
|
.xt.prop .xt.prop::00000000 .xt.prop::0004edbb 0x4edbc false false false
|
||||||
.xtensa.info .xtensa.info::00000000 .xtensa.info::00000037 0x38 false false false
|
.xtensa.info .xtensa.info::00000000 .xtensa.info::00000037 0x38 false false false
|
||||||
_elfSectionHeaders _elfSectionHeaders::00000000 _elfSectionHeaders::00001017 0x1018 false false false
|
_elfSectionHeaders _elfSectionHeaders::00000000 _elfSectionHeaders::00001017 0x1018 false false false
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381e61265560594118100" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381e61265560594118100" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="esp32s3_rev0_rom.elf" />
|
<STATE NAME="NAME" TYPE="string" VALUE="esp32s3_rev0_rom.elf" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
00000000:esp32s3_rev0_rom.elf:c0a8381e61265560594118100
|
00000000:esp32s3_rev0_rom.elf:c0a8381e61265560594118100
|
||||||
NEXT-ID:1
|
NEXT-ID:1
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="OWNER" TYPE="string" VALUE="human" />
|
<STATE NAME="OWNER" TYPE="string" VALUE="human" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381ec2072237217544300" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381ec2072237217544300" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381e61265560594118100" />
|
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381e61265560594118100" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
00000000:udf_c0a8381e61265560594118100:c0a8381ec2072237217544300
|
00000000:udf_c0a8381e61265560594118100:c0a8381ec2072237217544300
|
||||||
NEXT-ID:1
|
NEXT-ID:1
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
NEXT-ID:0
|
NEXT-ID:0
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# esp-bootrom-exploit
|
# esp-bootrom-exploit
|
||||||
Working on an exploit to break the security on the ESP32-S3
|
Working on an exploit to break the security on the ESP32-S3
|
||||||
Highly a work in progress
|
Highly a work in progress
|
||||||
|
|
||||||
[entropy](entropy/) - entropy images of the bootroms
|
[entropy](entropy/) - entropy images of the bootroms
|
||||||
[esp-rom-elfs-20230320](esp-rom-elfs-20230320/) - all of the ESP32-X bootloader elfs from [here](https://github.com/espressif/esp-rom-elfs/releases/tag/20230320)
|
[esp-rom-elfs-20230320](esp-rom-elfs-20230320/) - all of the ESP32-X bootloader elfs from [here](https://github.com/espressif/esp-rom-elfs/releases/tag/20230320)
|
||||||
[ESP32-S3_Exploit_FPGA](ESP32-S3_Exploit_FPGA/) - runs the exploit, based on a cheap [Tang Nano 9K FPGA](https://www.aliexpress.us/item/3256807026232976.html?channel=twinner) using [Lushay Code](https://learn.lushaylabs.com/vscode-extension/) for VS Code
|
[ESP32-S3_Exploit_FPGA](ESP32-S3_Exploit_FPGA/) - runs the exploit, based on a cheap [Tang Nano 9K FPGA](https://www.aliexpress.us/item/3256807026232976.html?channel=twinner) using [Lushay Code](https://learn.lushaylabs.com/vscode-extension/) for VS Code
|
||||||
[existing_files](existing_files/) - assorted existing roms I found
|
[existing_files](existing_files/) - assorted existing roms I found
|
||||||
[Ghidra](Ghidra/) - Ghidra project for reverse engineering and exploit dev
|
[Ghidra](Ghidra/) - Ghidra project for reverse engineering and exploit dev
|
||||||
[libs](libs/) - extra libraries that Espressif disclosed was used in the roms, excepting those found natively in esp-idf (useful for reverse engineering and debugging)
|
[libs](libs/) - extra libraries that Espressif disclosed was used in the roms, excepting those found natively in esp-idf (useful for reverse engineering and debugging)
|
||||||
[sillyfillyespdumper](sillyfillyespdumper/) - tool I made to dump arbitrary data from ESP32-Xs
|
[sillyfillyespdumper](sillyfillyespdumper/) - tool I made to dump arbitrary data from ESP32-Xs
|
||||||
[silltfillyespdumper/live-roms](sillyfillyespdumper/live-roms/) - full, redundant rom dumps from two production ESP32-S3s
|
[silltfillyespdumper/live-roms](sillyfillyespdumper/live-roms/) - full, redundant rom dumps from two production ESP32-S3s
|
||||||
|
|
||||||
|
|
||||||
Based much on [Coruk's attack on the ESP32-C3](https://courk.cc/esp32-c3-c6-fault-injection)
|
Based much on [Coruk's attack on the ESP32-C3](https://courk.cc/esp32-c3-c6-fault-injection)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381e17a248706805679800" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381e17a248706805679800" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="esp32s3_rev0_rom.elf" />
|
<STATE NAME="NAME" TYPE="string" VALUE="esp32s3_rev0_rom.elf" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381e1bb248882247094000" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381e1bb248882247094000" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="qemu_esp32s3_rev0_rom.bin" />
|
<STATE NAME="NAME" TYPE="string" VALUE="qemu_esp32s3_rev0_rom.bin" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381de636534513122800" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381de636534513122800" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="second.o" />
|
<STATE NAME="NAME" TYPE="string" VALUE="second.o" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="Program" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381bcb552259264623100" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381bcb552259264623100" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="esp32-s3-devkit-1-v1.1_internal-ROM0-0x4000_0000-0x3FFFF_instruction-bus_256K_stub_empty-flash.bin" />
|
<STATE NAME="NAME" TYPE="string" VALUE="esp32-s3-devkit-1-v1.1_internal-ROM0-0x4000_0000-0x3FFFF_instruction-bus_256K_stub_empty-flash.bin" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
00000003:esp32-s3-devkit-1-v1.1_internal-ROM0-0x4000_0000-0x3FFFF_instruction-bus_256K_stub_empty-flash.bin:c0a8381bcb552259264623100
|
00000003:esp32-s3-devkit-1-v1.1_internal-ROM0-0x4000_0000-0x3FFFF_instruction-bus_256K_stub_empty-flash.bin:c0a8381bcb552259264623100
|
||||||
00000000:esp32s3_rev0_rom.elf:c0a8381e17a248706805679800
|
00000000:esp32s3_rev0_rom.elf:c0a8381e17a248706805679800
|
||||||
00000001:qemu_esp32s3_rev0_rom.bin:c0a8381e1bb248882247094000
|
00000001:qemu_esp32s3_rev0_rom.bin:c0a8381e1bb248882247094000
|
||||||
00000002:second.o:c0a8381de636534513122800
|
00000002:second.o:c0a8381de636534513122800
|
||||||
NEXT-ID:4
|
NEXT-ID:4
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
00000003:esp32-s3-devkit-1-v1.1_internal-ROM0-0x4000_0000-0x3FFFF_instruction-bus_256K_stub_empty-flash.bin:c0a8381bcb552259264623100
|
00000003:esp32-s3-devkit-1-v1.1_internal-ROM0-0x4000_0000-0x3FFFF_instruction-bus_256K_stub_empty-flash.bin:c0a8381bcb552259264623100
|
||||||
00000000:esp32s3_rev0_rom.elf:c0a8381e17a248706805679800
|
00000000:esp32s3_rev0_rom.elf:c0a8381e17a248706805679800
|
||||||
00000001:qemu_esp32s3_rev0_rom.bin:c0a8381e1bb248882247094000
|
00000001:qemu_esp32s3_rev0_rom.bin:c0a8381e1bb248882247094000
|
||||||
00000002:second.o:c0a8381de636534513122800
|
00000002:second.o:c0a8381de636534513122800
|
||||||
NEXT-ID:4
|
NEXT-ID:4
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="OWNER" TYPE="string" VALUE="human" />
|
<STATE NAME="OWNER" TYPE="string" VALUE="human" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<PROJECT>
|
<PROJECT>
|
||||||
<PROJECT_DATA_XML_NAME NAME="DISPLAY_DATA">
|
<PROJECT_DATA_XML_NAME NAME="DISPLAY_DATA">
|
||||||
<SAVE_STATE>
|
<SAVE_STATE>
|
||||||
<ARRAY NAME="EXPANDED_PATHS" TYPE="string">
|
<ARRAY NAME="EXPANDED_PATHS" TYPE="string">
|
||||||
<A VALUE="XTENSABOOTROM:" />
|
<A VALUE="XTENSABOOTROM:" />
|
||||||
</ARRAY>
|
</ARRAY>
|
||||||
<STATE NAME="SHOW_TABLE" TYPE="boolean" VALUE="false" />
|
<STATE NAME="SHOW_TABLE" TYPE="boolean" VALUE="false" />
|
||||||
</SAVE_STATE>
|
</SAVE_STATE>
|
||||||
</PROJECT_DATA_XML_NAME>
|
</PROJECT_DATA_XML_NAME>
|
||||||
<TOOL_MANAGER ACTIVE_WORKSPACE="Workspace">
|
<TOOL_MANAGER ACTIVE_WORKSPACE="Workspace">
|
||||||
<WORKSPACE NAME="Workspace" ACTIVE="true" />
|
<WORKSPACE NAME="Workspace" ACTIVE="true" />
|
||||||
</TOOL_MANAGER>
|
</TOOL_MANAGER>
|
||||||
</PROJECT>
|
</PROJECT>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381d5332590910137400" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381d5332590910137400" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381e1bb248882247094000" />
|
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381e1bb248882247094000" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381d5342590954634300" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381d5342590954634300" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381e17a248706805679800" />
|
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381e17a248706805679800" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381f05515177828920600" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381f05515177828920600" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381de636534513122800" />
|
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381de636534513122800" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<FILE_INFO>
|
<FILE_INFO>
|
||||||
<BASIC_INFO>
|
<BASIC_INFO>
|
||||||
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
<STATE NAME="CONTENT_TYPE" TYPE="string" VALUE="ProgramUserData" />
|
||||||
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
<STATE NAME="PARENT" TYPE="string" VALUE="/" />
|
||||||
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381bd1752441915334200" />
|
<STATE NAME="FILE_ID" TYPE="string" VALUE="c0a8381bd1752441915334200" />
|
||||||
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
<STATE NAME="FILE_TYPE" TYPE="int" VALUE="0" />
|
||||||
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
<STATE NAME="READ_ONLY" TYPE="boolean" VALUE="false" />
|
||||||
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381bcb552259264623100" />
|
<STATE NAME="NAME" TYPE="string" VALUE="udf_c0a8381bcb552259264623100" />
|
||||||
</BASIC_INFO>
|
</BASIC_INFO>
|
||||||
</FILE_INFO>
|
</FILE_INFO>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
00000002:udf_c0a8381de636534513122800:c0a8381f05515177828920600
|
00000002:udf_c0a8381de636534513122800:c0a8381f05515177828920600
|
||||||
00000001:udf_c0a8381e17a248706805679800:c0a8381d5342590954634300
|
00000001:udf_c0a8381e17a248706805679800:c0a8381d5342590954634300
|
||||||
00000000:udf_c0a8381e1bb248882247094000:c0a8381d5332590910137400
|
00000000:udf_c0a8381e1bb248882247094000:c0a8381d5332590910137400
|
||||||
NEXT-ID:3
|
NEXT-ID:3
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
00000003:udf_c0a8381bcb552259264623100:c0a8381bd1752441915334200
|
00000003:udf_c0a8381bcb552259264623100:c0a8381bd1752441915334200
|
||||||
00000002:udf_c0a8381de636534513122800:c0a8381f05515177828920600
|
00000002:udf_c0a8381de636534513122800:c0a8381f05515177828920600
|
||||||
00000001:udf_c0a8381e17a248706805679800:c0a8381d5342590954634300
|
00000001:udf_c0a8381e17a248706805679800:c0a8381d5342590954634300
|
||||||
00000000:udf_c0a8381e1bb248882247094000:c0a8381d5332590910137400
|
00000000:udf_c0a8381e1bb248882247094000:c0a8381d5332590910137400
|
||||||
NEXT-ID:4
|
NEXT-ID:4
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
IADD:00000003:/udf_c0a8381bcb552259264623100
|
IADD:00000003:/udf_c0a8381bcb552259264623100
|
||||||
IDSET:/udf_c0a8381bcb552259264623100:c0a8381bd1752441915334200
|
IDSET:/udf_c0a8381bcb552259264623100:c0a8381bd1752441915334200
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
NEXT-ID:0
|
NEXT-ID:0
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
VERSION=1
|
VERSION=1
|
||||||
/
|
/
|
||||||
NEXT-ID:0
|
NEXT-ID:0
|
||||||
MD5:d41d8cd98f00b204e9800998ecf8427e
|
MD5:d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|||||||
+105
-105
@@ -1,105 +1,105 @@
|
|||||||
// example1.c - Demonstrates miniz.c's compress() and uncompress() functions (same as zlib's).
|
// example1.c - Demonstrates miniz.c's compress() and uncompress() functions (same as zlib's).
|
||||||
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
||||||
#include "miniz.c"
|
#include "miniz.c"
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
// The string to compress.
|
// The string to compress.
|
||||||
static const char *s_pStr = "Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
static const char *s_pStr = "Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
||||||
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
||||||
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
||||||
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
||||||
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
||||||
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson." \
|
||||||
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson.";
|
"Good morning Dr. Chandra. This is Hal. I am ready for my first lesson.";
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
uint step = 0;
|
uint step = 0;
|
||||||
int cmp_status;
|
int cmp_status;
|
||||||
uLong src_len = (uLong)strlen(s_pStr);
|
uLong src_len = (uLong)strlen(s_pStr);
|
||||||
uLong cmp_len = compressBound(src_len);
|
uLong cmp_len = compressBound(src_len);
|
||||||
uLong uncomp_len = src_len;
|
uLong uncomp_len = src_len;
|
||||||
uint8 *pCmp, *pUncomp;
|
uint8 *pCmp, *pUncomp;
|
||||||
uint total_succeeded = 0;
|
uint total_succeeded = 0;
|
||||||
(void)argc, (void)argv;
|
(void)argc, (void)argv;
|
||||||
|
|
||||||
printf("miniz.c version: %s\n", MZ_VERSION);
|
printf("miniz.c version: %s\n", MZ_VERSION);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Allocate buffers to hold compressed and uncompressed data.
|
// Allocate buffers to hold compressed and uncompressed data.
|
||||||
pCmp = (mz_uint8 *)malloc((size_t)cmp_len);
|
pCmp = (mz_uint8 *)malloc((size_t)cmp_len);
|
||||||
pUncomp = (mz_uint8 *)malloc((size_t)src_len);
|
pUncomp = (mz_uint8 *)malloc((size_t)src_len);
|
||||||
if ((!pCmp) || (!pUncomp))
|
if ((!pCmp) || (!pUncomp))
|
||||||
{
|
{
|
||||||
printf("Out of memory!\n");
|
printf("Out of memory!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compress the string.
|
// Compress the string.
|
||||||
cmp_status = compress(pCmp, &cmp_len, (const unsigned char *)s_pStr, src_len);
|
cmp_status = compress(pCmp, &cmp_len, (const unsigned char *)s_pStr, src_len);
|
||||||
if (cmp_status != Z_OK)
|
if (cmp_status != Z_OK)
|
||||||
{
|
{
|
||||||
printf("compress() failed!\n");
|
printf("compress() failed!\n");
|
||||||
free(pCmp);
|
free(pCmp);
|
||||||
free(pUncomp);
|
free(pUncomp);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Compressed from %u to %u bytes\n", (mz_uint32)src_len, (mz_uint32)cmp_len);
|
printf("Compressed from %u to %u bytes\n", (mz_uint32)src_len, (mz_uint32)cmp_len);
|
||||||
|
|
||||||
if (step)
|
if (step)
|
||||||
{
|
{
|
||||||
// Purposely corrupt the compressed data if fuzzy testing (this is a very crude fuzzy test).
|
// Purposely corrupt the compressed data if fuzzy testing (this is a very crude fuzzy test).
|
||||||
uint n = 1 + (rand() % 3);
|
uint n = 1 + (rand() % 3);
|
||||||
while (n--)
|
while (n--)
|
||||||
{
|
{
|
||||||
uint i = rand() % cmp_len;
|
uint i = rand() % cmp_len;
|
||||||
pCmp[i] ^= (rand() & 0xFF);
|
pCmp[i] ^= (rand() & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decompress.
|
// Decompress.
|
||||||
cmp_status = uncompress(pUncomp, &uncomp_len, pCmp, cmp_len);
|
cmp_status = uncompress(pUncomp, &uncomp_len, pCmp, cmp_len);
|
||||||
total_succeeded += (cmp_status == Z_OK);
|
total_succeeded += (cmp_status == Z_OK);
|
||||||
|
|
||||||
if (step)
|
if (step)
|
||||||
{
|
{
|
||||||
printf("Simple fuzzy test: step %u total_succeeded: %u\n", step, total_succeeded);
|
printf("Simple fuzzy test: step %u total_succeeded: %u\n", step, total_succeeded);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cmp_status != Z_OK)
|
if (cmp_status != Z_OK)
|
||||||
{
|
{
|
||||||
printf("uncompress failed!\n");
|
printf("uncompress failed!\n");
|
||||||
free(pCmp);
|
free(pCmp);
|
||||||
free(pUncomp);
|
free(pUncomp);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Decompressed from %u to %u bytes\n", (mz_uint32)cmp_len, (mz_uint32)uncomp_len);
|
printf("Decompressed from %u to %u bytes\n", (mz_uint32)cmp_len, (mz_uint32)uncomp_len);
|
||||||
|
|
||||||
// Ensure uncompress() returned the expected data.
|
// Ensure uncompress() returned the expected data.
|
||||||
if ((uncomp_len != src_len) || (memcmp(pUncomp, s_pStr, (size_t)src_len)))
|
if ((uncomp_len != src_len) || (memcmp(pUncomp, s_pStr, (size_t)src_len)))
|
||||||
{
|
{
|
||||||
printf("Decompression failed!\n");
|
printf("Decompression failed!\n");
|
||||||
free(pCmp);
|
free(pCmp);
|
||||||
free(pUncomp);
|
free(pUncomp);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pCmp);
|
free(pCmp);
|
||||||
free(pUncomp);
|
free(pUncomp);
|
||||||
|
|
||||||
step++;
|
step++;
|
||||||
|
|
||||||
// Keep on fuzzy testing if there's a non-empty command line.
|
// Keep on fuzzy testing if there's a non-empty command line.
|
||||||
} while (argc >= 2);
|
} while (argc >= 2);
|
||||||
|
|
||||||
printf("Success.\n");
|
printf("Success.\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+346
-346
@@ -1,346 +1,346 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="example1"
|
Name="example1"
|
||||||
ProjectGUID="{BE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
ProjectGUID="{BE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
||||||
RootNamespace="example1"
|
RootNamespace="example1"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="196613"
|
TargetFrameworkVersion="196613"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
<Platform
|
<Platform
|
||||||
Name="x64"
|
Name="x64"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\example1.c"
|
RelativePath=".\example1.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
+163
-163
@@ -1,163 +1,163 @@
|
|||||||
// example2.c - Simple demonstration of miniz.c's ZIP archive API's.
|
// example2.c - Simple demonstration of miniz.c's ZIP archive API's.
|
||||||
// Note this test deletes the test archive file "__mz_example2_test__.zip" in the current directory, then creates a new one with test data.
|
// Note this test deletes the test archive file "__mz_example2_test__.zip" in the current directory, then creates a new one with test data.
|
||||||
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
// Ensure we get the 64-bit variants of the CRT's file I/O calls
|
// Ensure we get the 64-bit variants of the CRT's file I/O calls
|
||||||
#ifndef _FILE_OFFSET_BITS
|
#ifndef _FILE_OFFSET_BITS
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#endif
|
#endif
|
||||||
#ifndef _LARGEFILE64_SOURCE
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
#define _LARGEFILE64_SOURCE 1
|
#define _LARGEFILE64_SOURCE 1
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "miniz.c"
|
#include "miniz.c"
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
// The string to compress.
|
// The string to compress.
|
||||||
static const char *s_pTest_str =
|
static const char *s_pTest_str =
|
||||||
"MISSION CONTROL I wouldn't worry too much about the computer. First of all, there is still a chance that he is right, despite your tests, and" \
|
"MISSION CONTROL I wouldn't worry too much about the computer. First of all, there is still a chance that he is right, despite your tests, and" \
|
||||||
"if it should happen again, we suggest eliminating this possibility by allowing the unit to remain in place and seeing whether or not it" \
|
"if it should happen again, we suggest eliminating this possibility by allowing the unit to remain in place and seeing whether or not it" \
|
||||||
"actually fails. If the computer should turn out to be wrong, the situation is still not alarming. The type of obsessional error he may be" \
|
"actually fails. If the computer should turn out to be wrong, the situation is still not alarming. The type of obsessional error he may be" \
|
||||||
"guilty of is not unknown among the latest generation of HAL 9000 computers. It has almost always revolved around a single detail, such as" \
|
"guilty of is not unknown among the latest generation of HAL 9000 computers. It has almost always revolved around a single detail, such as" \
|
||||||
"the one you have described, and it has never interfered with the integrity or reliability of the computer's performance in other areas." \
|
"the one you have described, and it has never interfered with the integrity or reliability of the computer's performance in other areas." \
|
||||||
"No one is certain of the cause of this kind of malfunctioning. It may be over-programming, but it could also be any number of reasons. In any" \
|
"No one is certain of the cause of this kind of malfunctioning. It may be over-programming, but it could also be any number of reasons. In any" \
|
||||||
"event, it is somewhat analogous to human neurotic behavior. Does this answer your query? Zero-five-three-Zero, MC, transmission concluded.";
|
"event, it is somewhat analogous to human neurotic behavior. Does this answer your query? Zero-five-three-Zero, MC, transmission concluded.";
|
||||||
|
|
||||||
static const char *s_pComment = "This is a comment";
|
static const char *s_pComment = "This is a comment";
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, sort_iter;
|
int i, sort_iter;
|
||||||
mz_bool status;
|
mz_bool status;
|
||||||
size_t uncomp_size;
|
size_t uncomp_size;
|
||||||
mz_zip_archive zip_archive;
|
mz_zip_archive zip_archive;
|
||||||
void *p;
|
void *p;
|
||||||
const int N = 50;
|
const int N = 50;
|
||||||
char data[2048];
|
char data[2048];
|
||||||
char archive_filename[64];
|
char archive_filename[64];
|
||||||
static const char *s_Test_archive_filename = "__mz_example2_test__.zip";
|
static const char *s_Test_archive_filename = "__mz_example2_test__.zip";
|
||||||
|
|
||||||
assert((strlen(s_pTest_str) + 64) < sizeof(data));
|
assert((strlen(s_pTest_str) + 64) < sizeof(data));
|
||||||
|
|
||||||
printf("miniz.c version: %s\n", MZ_VERSION);
|
printf("miniz.c version: %s\n", MZ_VERSION);
|
||||||
|
|
||||||
(void)argc, (void)argv;
|
(void)argc, (void)argv;
|
||||||
|
|
||||||
// Delete the test archive, so it doesn't keep growing as we run this test
|
// Delete the test archive, so it doesn't keep growing as we run this test
|
||||||
remove(s_Test_archive_filename);
|
remove(s_Test_archive_filename);
|
||||||
|
|
||||||
// Append a bunch of text files to the test archive
|
// Append a bunch of text files to the test archive
|
||||||
for (i = (N - 1); i >= 0; --i)
|
for (i = (N - 1); i >= 0; --i)
|
||||||
{
|
{
|
||||||
sprintf(archive_filename, "%u.txt", i);
|
sprintf(archive_filename, "%u.txt", i);
|
||||||
sprintf(data, "%u %s %u", (N - 1) - i, s_pTest_str, i);
|
sprintf(data, "%u %s %u", (N - 1) - i, s_pTest_str, i);
|
||||||
|
|
||||||
// Add a new file to the archive. Note this is an IN-PLACE operation, so if it fails your archive is probably hosed (its central directory may not be complete) but it should be recoverable using zip -F or -FF. So use caution with this guy.
|
// Add a new file to the archive. Note this is an IN-PLACE operation, so if it fails your archive is probably hosed (its central directory may not be complete) but it should be recoverable using zip -F or -FF. So use caution with this guy.
|
||||||
// A more robust way to add a file to an archive would be to read it into memory, perform the operation, then write a new archive out to a temp file and then delete/rename the files.
|
// A more robust way to add a file to an archive would be to read it into memory, perform the operation, then write a new archive out to a temp file and then delete/rename the files.
|
||||||
// Or, write a new archive to disk to a temp file, then delete/rename the files. For this test this API is fine.
|
// Or, write a new archive to disk to a temp file, then delete/rename the files. For this test this API is fine.
|
||||||
status = mz_zip_add_mem_to_archive_file_in_place(s_Test_archive_filename, archive_filename, data, strlen(data) + 1, s_pComment, (uint16)strlen(s_pComment), MZ_BEST_COMPRESSION);
|
status = mz_zip_add_mem_to_archive_file_in_place(s_Test_archive_filename, archive_filename, data, strlen(data) + 1, s_pComment, (uint16)strlen(s_pComment), MZ_BEST_COMPRESSION);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_add_mem_to_archive_file_in_place failed!\n");
|
printf("mz_zip_add_mem_to_archive_file_in_place failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a directory entry for testing
|
// Add a directory entry for testing
|
||||||
status = mz_zip_add_mem_to_archive_file_in_place(s_Test_archive_filename, "directory/", NULL, 0, "no comment", (uint16)strlen("no comment"), MZ_BEST_COMPRESSION);
|
status = mz_zip_add_mem_to_archive_file_in_place(s_Test_archive_filename, "directory/", NULL, 0, "no comment", (uint16)strlen("no comment"), MZ_BEST_COMPRESSION);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_add_mem_to_archive_file_in_place failed!\n");
|
printf("mz_zip_add_mem_to_archive_file_in_place failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try to open the archive.
|
// Now try to open the archive.
|
||||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||||
|
|
||||||
status = mz_zip_reader_init_file(&zip_archive, s_Test_archive_filename, 0);
|
status = mz_zip_reader_init_file(&zip_archive, s_Test_archive_filename, 0);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_init_file() failed!\n");
|
printf("mz_zip_reader_init_file() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get and print information about each file in the archive.
|
// Get and print information about each file in the archive.
|
||||||
for (i = 0; i < (int)mz_zip_reader_get_num_files(&zip_archive); i++)
|
for (i = 0; i < (int)mz_zip_reader_get_num_files(&zip_archive); i++)
|
||||||
{
|
{
|
||||||
mz_zip_archive_file_stat file_stat;
|
mz_zip_archive_file_stat file_stat;
|
||||||
if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat))
|
if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat))
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_file_stat() failed!\n");
|
printf("mz_zip_reader_file_stat() failed!\n");
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u, Is Dir: %u\n", file_stat.m_filename, file_stat.m_comment, (uint)file_stat.m_uncomp_size, (uint)file_stat.m_comp_size, mz_zip_reader_is_file_a_directory(&zip_archive, i));
|
printf("Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u, Is Dir: %u\n", file_stat.m_filename, file_stat.m_comment, (uint)file_stat.m_uncomp_size, (uint)file_stat.m_comp_size, mz_zip_reader_is_file_a_directory(&zip_archive, i));
|
||||||
|
|
||||||
if (!strcmp(file_stat.m_filename, "directory/"))
|
if (!strcmp(file_stat.m_filename, "directory/"))
|
||||||
{
|
{
|
||||||
if (!mz_zip_reader_is_file_a_directory(&zip_archive, i))
|
if (!mz_zip_reader_is_file_a_directory(&zip_archive, i))
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_is_file_a_directory() didn't return the expected results!\n");
|
printf("mz_zip_reader_is_file_a_directory() didn't return the expected results!\n");
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the archive, freeing any resources it was using
|
// Close the archive, freeing any resources it was using
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
|
|
||||||
// Now verify the compressed data
|
// Now verify the compressed data
|
||||||
for (sort_iter = 0; sort_iter < 2; sort_iter++)
|
for (sort_iter = 0; sort_iter < 2; sort_iter++)
|
||||||
{
|
{
|
||||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||||
status = mz_zip_reader_init_file(&zip_archive, s_Test_archive_filename, sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
status = mz_zip_reader_init_file(&zip_archive, s_Test_archive_filename, sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_init_file() failed!\n");
|
printf("mz_zip_reader_init_file() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
sprintf(archive_filename, "%u.txt", i);
|
sprintf(archive_filename, "%u.txt", i);
|
||||||
sprintf(data, "%u %s %u", (N - 1) - i, s_pTest_str, i);
|
sprintf(data, "%u %s %u", (N - 1) - i, s_pTest_str, i);
|
||||||
|
|
||||||
// Try to extract all the files to the heap.
|
// Try to extract all the files to the heap.
|
||||||
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_extract_file_to_heap() failed!\n");
|
printf("mz_zip_reader_extract_file_to_heap() failed!\n");
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the extraction really succeeded.
|
// Make sure the extraction really succeeded.
|
||||||
if ((uncomp_size != (strlen(data) + 1)) || (memcmp(p, data, strlen(data))))
|
if ((uncomp_size != (strlen(data) + 1)) || (memcmp(p, data, strlen(data))))
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_extract_file_to_heap() failed to extract the proper data\n");
|
printf("mz_zip_reader_extract_file_to_heap() failed to extract the proper data\n");
|
||||||
mz_free(p);
|
mz_free(p);
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
|
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
|
||||||
printf("File data: \"%s\"\n", (const char *)p);
|
printf("File data: \"%s\"\n", (const char *)p);
|
||||||
|
|
||||||
// We're done.
|
// We're done.
|
||||||
mz_free(p);
|
mz_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the archive, freeing any resources it was using
|
// Close the archive, freeing any resources it was using
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Success.\n");
|
printf("Success.\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+346
-346
@@ -1,346 +1,346 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="example2"
|
Name="example2"
|
||||||
ProjectGUID="{AE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
ProjectGUID="{AE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
||||||
RootNamespace="example2"
|
RootNamespace="example2"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="196613"
|
TargetFrameworkVersion="196613"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
<Platform
|
<Platform
|
||||||
Name="x64"
|
Name="x64"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\example2.c"
|
RelativePath=".\example2.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
+268
-268
@@ -1,268 +1,268 @@
|
|||||||
// example3.c - Demonstrates how to use miniz.c's deflate() and inflate() functions for simple file compression.
|
// example3.c - Demonstrates how to use miniz.c's deflate() and inflate() functions for simple file compression.
|
||||||
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
||||||
// For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c.
|
// For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c.
|
||||||
#include "miniz.c"
|
#include "miniz.c"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
#define my_max(a,b) (((a) > (b)) ? (a) : (b))
|
#define my_max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#define my_min(a,b) (((a) < (b)) ? (a) : (b))
|
#define my_min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
#define BUF_SIZE (1024 * 1024)
|
#define BUF_SIZE (1024 * 1024)
|
||||||
static uint8 s_inbuf[BUF_SIZE];
|
static uint8 s_inbuf[BUF_SIZE];
|
||||||
static uint8 s_outbuf[BUF_SIZE];
|
static uint8 s_outbuf[BUF_SIZE];
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *pMode;
|
const char *pMode;
|
||||||
FILE *pInfile, *pOutfile;
|
FILE *pInfile, *pOutfile;
|
||||||
uint infile_size;
|
uint infile_size;
|
||||||
int level = Z_BEST_COMPRESSION;
|
int level = Z_BEST_COMPRESSION;
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int p = 1;
|
int p = 1;
|
||||||
const char *pSrc_filename;
|
const char *pSrc_filename;
|
||||||
const char *pDst_filename;
|
const char *pDst_filename;
|
||||||
long file_loc;
|
long file_loc;
|
||||||
|
|
||||||
printf("miniz.c version: %s\n", MZ_VERSION);
|
printf("miniz.c version: %s\n", MZ_VERSION);
|
||||||
|
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
{
|
{
|
||||||
printf("Usage: example3 [options] [mode:c or d] infile outfile\n");
|
printf("Usage: example3 [options] [mode:c or d] infile outfile\n");
|
||||||
printf("\nModes:\n");
|
printf("\nModes:\n");
|
||||||
printf("c - Compresses file infile to a zlib stream in file outfile\n");
|
printf("c - Compresses file infile to a zlib stream in file outfile\n");
|
||||||
printf("d - Decompress zlib stream in file infile to file outfile\n");
|
printf("d - Decompress zlib stream in file infile to file outfile\n");
|
||||||
printf("\nOptions:\n");
|
printf("\nOptions:\n");
|
||||||
printf("-l[0-10] - Compression level, higher values are slower.\n");
|
printf("-l[0-10] - Compression level, higher values are slower.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((p < argc) && (argv[p][0] == '-'))
|
while ((p < argc) && (argv[p][0] == '-'))
|
||||||
{
|
{
|
||||||
switch (argv[p][1])
|
switch (argv[p][1])
|
||||||
{
|
{
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
level = atoi(&argv[1][2]);
|
level = atoi(&argv[1][2]);
|
||||||
if ((level < 0) || (level > 10))
|
if ((level < 0) || (level > 10))
|
||||||
{
|
{
|
||||||
printf("Invalid level!\n");
|
printf("Invalid level!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf("Invalid option: %s\n", argv[p]);
|
printf("Invalid option: %s\n", argv[p]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((argc - p) < 3)
|
if ((argc - p) < 3)
|
||||||
{
|
{
|
||||||
printf("Must specify mode, input filename, and output filename after options!\n");
|
printf("Must specify mode, input filename, and output filename after options!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else if ((argc - p) > 3)
|
else if ((argc - p) > 3)
|
||||||
{
|
{
|
||||||
printf("Too many filenames!\n");
|
printf("Too many filenames!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMode = argv[p++];
|
pMode = argv[p++];
|
||||||
if (!strchr("cCdD", pMode[0]))
|
if (!strchr("cCdD", pMode[0]))
|
||||||
{
|
{
|
||||||
printf("Invalid mode!\n");
|
printf("Invalid mode!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSrc_filename = argv[p++];
|
pSrc_filename = argv[p++];
|
||||||
pDst_filename = argv[p++];
|
pDst_filename = argv[p++];
|
||||||
|
|
||||||
printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename);
|
printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename);
|
||||||
|
|
||||||
// Open input file.
|
// Open input file.
|
||||||
pInfile = fopen(pSrc_filename, "rb");
|
pInfile = fopen(pSrc_filename, "rb");
|
||||||
if (!pInfile)
|
if (!pInfile)
|
||||||
{
|
{
|
||||||
printf("Failed opening input file!\n");
|
printf("Failed opening input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine input file's size.
|
// Determine input file's size.
|
||||||
fseek(pInfile, 0, SEEK_END);
|
fseek(pInfile, 0, SEEK_END);
|
||||||
file_loc = ftell(pInfile);
|
file_loc = ftell(pInfile);
|
||||||
fseek(pInfile, 0, SEEK_SET);
|
fseek(pInfile, 0, SEEK_SET);
|
||||||
|
|
||||||
if ((file_loc < 0) || (file_loc > INT_MAX))
|
if ((file_loc < 0) || (file_loc > INT_MAX))
|
||||||
{
|
{
|
||||||
// This is not a limitation of miniz or tinfl, but this example.
|
// This is not a limitation of miniz or tinfl, but this example.
|
||||||
printf("File is too large to be processed by this example.\n");
|
printf("File is too large to be processed by this example.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
infile_size = (uint)file_loc;
|
infile_size = (uint)file_loc;
|
||||||
|
|
||||||
// Open output file.
|
// Open output file.
|
||||||
pOutfile = fopen(pDst_filename, "wb");
|
pOutfile = fopen(pDst_filename, "wb");
|
||||||
if (!pOutfile)
|
if (!pOutfile)
|
||||||
{
|
{
|
||||||
printf("Failed opening output file!\n");
|
printf("Failed opening output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Input file size: %u\n", infile_size);
|
printf("Input file size: %u\n", infile_size);
|
||||||
|
|
||||||
// Init the z_stream
|
// Init the z_stream
|
||||||
memset(&stream, 0, sizeof(stream));
|
memset(&stream, 0, sizeof(stream));
|
||||||
stream.next_in = s_inbuf;
|
stream.next_in = s_inbuf;
|
||||||
stream.avail_in = 0;
|
stream.avail_in = 0;
|
||||||
stream.next_out = s_outbuf;
|
stream.next_out = s_outbuf;
|
||||||
stream.avail_out = BUF_SIZE;
|
stream.avail_out = BUF_SIZE;
|
||||||
|
|
||||||
if ((pMode[0] == 'c') || (pMode[0] == 'C'))
|
if ((pMode[0] == 'c') || (pMode[0] == 'C'))
|
||||||
{
|
{
|
||||||
// Compression.
|
// Compression.
|
||||||
uint infile_remaining = infile_size;
|
uint infile_remaining = infile_size;
|
||||||
|
|
||||||
if (deflateInit(&stream, level) != Z_OK)
|
if (deflateInit(&stream, level) != Z_OK)
|
||||||
{
|
{
|
||||||
printf("deflateInit() failed!\n");
|
printf("deflateInit() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
if (!stream.avail_in)
|
if (!stream.avail_in)
|
||||||
{
|
{
|
||||||
// Input buffer is empty, so read more bytes from input file.
|
// Input buffer is empty, so read more bytes from input file.
|
||||||
uint n = my_min(BUF_SIZE, infile_remaining);
|
uint n = my_min(BUF_SIZE, infile_remaining);
|
||||||
|
|
||||||
if (fread(s_inbuf, 1, n, pInfile) != n)
|
if (fread(s_inbuf, 1, n, pInfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed reading from input file!\n");
|
printf("Failed reading from input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.next_in = s_inbuf;
|
stream.next_in = s_inbuf;
|
||||||
stream.avail_in = n;
|
stream.avail_in = n;
|
||||||
|
|
||||||
infile_remaining -= n;
|
infile_remaining -= n;
|
||||||
//printf("Input bytes remaining: %u\n", infile_remaining);
|
//printf("Input bytes remaining: %u\n", infile_remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = deflate(&stream, infile_remaining ? Z_NO_FLUSH : Z_FINISH);
|
status = deflate(&stream, infile_remaining ? Z_NO_FLUSH : Z_FINISH);
|
||||||
|
|
||||||
if ((status == Z_STREAM_END) || (!stream.avail_out))
|
if ((status == Z_STREAM_END) || (!stream.avail_out))
|
||||||
{
|
{
|
||||||
// Output buffer is full, or compression is done, so write buffer to output file.
|
// Output buffer is full, or compression is done, so write buffer to output file.
|
||||||
uint n = BUF_SIZE - stream.avail_out;
|
uint n = BUF_SIZE - stream.avail_out;
|
||||||
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
stream.next_out = s_outbuf;
|
stream.next_out = s_outbuf;
|
||||||
stream.avail_out = BUF_SIZE;
|
stream.avail_out = BUF_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == Z_STREAM_END)
|
if (status == Z_STREAM_END)
|
||||||
break;
|
break;
|
||||||
else if (status != Z_OK)
|
else if (status != Z_OK)
|
||||||
{
|
{
|
||||||
printf("deflate() failed with status %i!\n", status);
|
printf("deflate() failed with status %i!\n", status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deflateEnd(&stream) != Z_OK)
|
if (deflateEnd(&stream) != Z_OK)
|
||||||
{
|
{
|
||||||
printf("deflateEnd() failed!\n");
|
printf("deflateEnd() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((pMode[0] == 'd') || (pMode[0] == 'D'))
|
else if ((pMode[0] == 'd') || (pMode[0] == 'D'))
|
||||||
{
|
{
|
||||||
// Decompression.
|
// Decompression.
|
||||||
uint infile_remaining = infile_size;
|
uint infile_remaining = infile_size;
|
||||||
|
|
||||||
if (inflateInit(&stream))
|
if (inflateInit(&stream))
|
||||||
{
|
{
|
||||||
printf("inflateInit() failed!\n");
|
printf("inflateInit() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
if (!stream.avail_in)
|
if (!stream.avail_in)
|
||||||
{
|
{
|
||||||
// Input buffer is empty, so read more bytes from input file.
|
// Input buffer is empty, so read more bytes from input file.
|
||||||
uint n = my_min(BUF_SIZE, infile_remaining);
|
uint n = my_min(BUF_SIZE, infile_remaining);
|
||||||
|
|
||||||
if (fread(s_inbuf, 1, n, pInfile) != n)
|
if (fread(s_inbuf, 1, n, pInfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed reading from input file!\n");
|
printf("Failed reading from input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.next_in = s_inbuf;
|
stream.next_in = s_inbuf;
|
||||||
stream.avail_in = n;
|
stream.avail_in = n;
|
||||||
|
|
||||||
infile_remaining -= n;
|
infile_remaining -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = inflate(&stream, Z_SYNC_FLUSH);
|
status = inflate(&stream, Z_SYNC_FLUSH);
|
||||||
|
|
||||||
if ((status == Z_STREAM_END) || (!stream.avail_out))
|
if ((status == Z_STREAM_END) || (!stream.avail_out))
|
||||||
{
|
{
|
||||||
// Output buffer is full, or decompression is done, so write buffer to output file.
|
// Output buffer is full, or decompression is done, so write buffer to output file.
|
||||||
uint n = BUF_SIZE - stream.avail_out;
|
uint n = BUF_SIZE - stream.avail_out;
|
||||||
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
stream.next_out = s_outbuf;
|
stream.next_out = s_outbuf;
|
||||||
stream.avail_out = BUF_SIZE;
|
stream.avail_out = BUF_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == Z_STREAM_END)
|
if (status == Z_STREAM_END)
|
||||||
break;
|
break;
|
||||||
else if (status != Z_OK)
|
else if (status != Z_OK)
|
||||||
{
|
{
|
||||||
printf("inflate() failed with status %i!\n", status);
|
printf("inflate() failed with status %i!\n", status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inflateEnd(&stream) != Z_OK)
|
if (inflateEnd(&stream) != Z_OK)
|
||||||
{
|
{
|
||||||
printf("inflateEnd() failed!\n");
|
printf("inflateEnd() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Invalid mode!\n");
|
printf("Invalid mode!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(pInfile);
|
fclose(pInfile);
|
||||||
if (EOF == fclose(pOutfile))
|
if (EOF == fclose(pOutfile))
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Total input bytes: %u\n", (mz_uint32)stream.total_in);
|
printf("Total input bytes: %u\n", (mz_uint32)stream.total_in);
|
||||||
printf("Total output bytes: %u\n", (mz_uint32)stream.total_out);
|
printf("Total output bytes: %u\n", (mz_uint32)stream.total_out);
|
||||||
printf("Success.\n");
|
printf("Success.\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+346
-346
@@ -1,346 +1,346 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="example3"
|
Name="example3"
|
||||||
ProjectGUID="{AE273522-92D8-4B60-95C7-C3AEE10A303F}"
|
ProjectGUID="{AE273522-92D8-4B60-95C7-C3AEE10A303F}"
|
||||||
RootNamespace="example3"
|
RootNamespace="example3"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="196613"
|
TargetFrameworkVersion="196613"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
<Platform
|
<Platform
|
||||||
Name="x64"
|
Name="x64"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\example3.c"
|
RelativePath=".\example3.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
+102
-102
@@ -1,102 +1,102 @@
|
|||||||
// example4.c - Uses tinfl.c to decompress a zlib stream in memory to an output file
|
// example4.c - Uses tinfl.c to decompress a zlib stream in memory to an output file
|
||||||
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
// Public domain, May 15 2011, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
||||||
#include "tinfl.c"
|
#include "tinfl.c"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
#define my_max(a,b) (((a) > (b)) ? (a) : (b))
|
#define my_max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#define my_min(a,b) (((a) < (b)) ? (a) : (b))
|
#define my_min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
static int tinfl_put_buf_func(const void* pBuf, int len, void *pUser)
|
static int tinfl_put_buf_func(const void* pBuf, int len, void *pUser)
|
||||||
{
|
{
|
||||||
return len == (int)fwrite(pBuf, 1, len, (FILE*)pUser);
|
return len == (int)fwrite(pBuf, 1, len, (FILE*)pUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
FILE *pInfile, *pOutfile;
|
FILE *pInfile, *pOutfile;
|
||||||
uint infile_size, outfile_size;
|
uint infile_size, outfile_size;
|
||||||
size_t in_buf_size;
|
size_t in_buf_size;
|
||||||
uint8 *pCmp_data;
|
uint8 *pCmp_data;
|
||||||
long file_loc;
|
long file_loc;
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
{
|
{
|
||||||
printf("Usage: example4 infile outfile\n");
|
printf("Usage: example4 infile outfile\n");
|
||||||
printf("Decompresses zlib stream in file infile to file outfile.\n");
|
printf("Decompresses zlib stream in file infile to file outfile.\n");
|
||||||
printf("Input file must be able to fit entirely in memory.\n");
|
printf("Input file must be able to fit entirely in memory.\n");
|
||||||
printf("example3 can be used to create compressed zlib streams.\n");
|
printf("example3 can be used to create compressed zlib streams.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open input file.
|
// Open input file.
|
||||||
pInfile = fopen(argv[1], "rb");
|
pInfile = fopen(argv[1], "rb");
|
||||||
if (!pInfile)
|
if (!pInfile)
|
||||||
{
|
{
|
||||||
printf("Failed opening input file!\n");
|
printf("Failed opening input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine input file's size.
|
// Determine input file's size.
|
||||||
fseek(pInfile, 0, SEEK_END);
|
fseek(pInfile, 0, SEEK_END);
|
||||||
file_loc = ftell(pInfile);
|
file_loc = ftell(pInfile);
|
||||||
fseek(pInfile, 0, SEEK_SET);
|
fseek(pInfile, 0, SEEK_SET);
|
||||||
|
|
||||||
if ((file_loc < 0) || (file_loc > INT_MAX))
|
if ((file_loc < 0) || (file_loc > INT_MAX))
|
||||||
{
|
{
|
||||||
// This is not a limitation of miniz or tinfl, but this example.
|
// This is not a limitation of miniz or tinfl, but this example.
|
||||||
printf("File is too large to be processed by this example.\n");
|
printf("File is too large to be processed by this example.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
infile_size = (uint)file_loc;
|
infile_size = (uint)file_loc;
|
||||||
|
|
||||||
pCmp_data = (uint8 *)malloc(infile_size);
|
pCmp_data = (uint8 *)malloc(infile_size);
|
||||||
if (!pCmp_data)
|
if (!pCmp_data)
|
||||||
{
|
{
|
||||||
printf("Out of memory!\n");
|
printf("Out of memory!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (fread(pCmp_data, 1, infile_size, pInfile) != infile_size)
|
if (fread(pCmp_data, 1, infile_size, pInfile) != infile_size)
|
||||||
{
|
{
|
||||||
printf("Failed reading input file!\n");
|
printf("Failed reading input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open output file.
|
// Open output file.
|
||||||
pOutfile = fopen(argv[2], "wb");
|
pOutfile = fopen(argv[2], "wb");
|
||||||
if (!pOutfile)
|
if (!pOutfile)
|
||||||
{
|
{
|
||||||
printf("Failed opening output file!\n");
|
printf("Failed opening output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Input file size: %u\n", infile_size);
|
printf("Input file size: %u\n", infile_size);
|
||||||
|
|
||||||
in_buf_size = infile_size;
|
in_buf_size = infile_size;
|
||||||
status = tinfl_decompress_mem_to_callback(pCmp_data, &in_buf_size, tinfl_put_buf_func, pOutfile, TINFL_FLAG_PARSE_ZLIB_HEADER);
|
status = tinfl_decompress_mem_to_callback(pCmp_data, &in_buf_size, tinfl_put_buf_func, pOutfile, TINFL_FLAG_PARSE_ZLIB_HEADER);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("tinfl_decompress_mem_to_callback() failed with status %i!\n", status);
|
printf("tinfl_decompress_mem_to_callback() failed with status %i!\n", status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile_size = ftell(pOutfile);
|
outfile_size = ftell(pOutfile);
|
||||||
|
|
||||||
fclose(pInfile);
|
fclose(pInfile);
|
||||||
if (EOF == fclose(pOutfile))
|
if (EOF == fclose(pOutfile))
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Total input bytes: %u\n", (uint)in_buf_size);
|
printf("Total input bytes: %u\n", (uint)in_buf_size);
|
||||||
printf("Total output bytes: %u\n", outfile_size);
|
printf("Total output bytes: %u\n", outfile_size);
|
||||||
printf("Success.\n");
|
printf("Success.\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+346
-346
@@ -1,346 +1,346 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="example4"
|
Name="example4"
|
||||||
ProjectGUID="{AE293522-92D8-4B60-95C7-C3AEE10A303F}"
|
ProjectGUID="{AE293522-92D8-4B60-95C7-C3AEE10A303F}"
|
||||||
RootNamespace="example4"
|
RootNamespace="example4"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="196613"
|
TargetFrameworkVersion="196613"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
<Platform
|
<Platform
|
||||||
Name="x64"
|
Name="x64"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\example4.c"
|
RelativePath=".\example4.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
+327
-327
@@ -1,327 +1,327 @@
|
|||||||
// example5.c - Demonstrates how to use miniz.c's low-level tdefl_compress() and tinfl_inflate() API's for simple file to file compression/decompression.
|
// example5.c - Demonstrates how to use miniz.c's low-level tdefl_compress() and tinfl_inflate() API's for simple file to file compression/decompression.
|
||||||
// The low-level API's are the fastest, make no use of dynamic memory allocation, and are the most flexible functions exposed by miniz.c.
|
// The low-level API's are the fastest, make no use of dynamic memory allocation, and are the most flexible functions exposed by miniz.c.
|
||||||
// Public domain, April 11 2012, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
// Public domain, April 11 2012, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
||||||
// For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c.
|
// For simplicity, this example is limited to files smaller than 4GB, but this is not a limitation of miniz.c.
|
||||||
|
|
||||||
// Purposely disable a whole bunch of stuff this low-level example doesn't use.
|
// Purposely disable a whole bunch of stuff this low-level example doesn't use.
|
||||||
#define MINIZ_NO_STDIO
|
#define MINIZ_NO_STDIO
|
||||||
#define MINIZ_NO_ARCHIVE_APIS
|
#define MINIZ_NO_ARCHIVE_APIS
|
||||||
#define MINIZ_NO_TIME
|
#define MINIZ_NO_TIME
|
||||||
#define MINIZ_NO_ZLIB_APIS
|
#define MINIZ_NO_ZLIB_APIS
|
||||||
#define MINIZ_NO_MALLOC
|
#define MINIZ_NO_MALLOC
|
||||||
#include "miniz.c"
|
#include "miniz.c"
|
||||||
|
|
||||||
// Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing).
|
// Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing).
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
#define my_max(a,b) (((a) > (b)) ? (a) : (b))
|
#define my_max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#define my_min(a,b) (((a) < (b)) ? (a) : (b))
|
#define my_min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
// IN_BUF_SIZE is the size of the file read buffer.
|
// IN_BUF_SIZE is the size of the file read buffer.
|
||||||
// IN_BUF_SIZE must be >= 1
|
// IN_BUF_SIZE must be >= 1
|
||||||
#define IN_BUF_SIZE (1024*512)
|
#define IN_BUF_SIZE (1024*512)
|
||||||
static uint8 s_inbuf[IN_BUF_SIZE];
|
static uint8 s_inbuf[IN_BUF_SIZE];
|
||||||
|
|
||||||
// COMP_OUT_BUF_SIZE is the size of the output buffer used during compression.
|
// COMP_OUT_BUF_SIZE is the size of the output buffer used during compression.
|
||||||
// COMP_OUT_BUF_SIZE must be >= 1 and <= OUT_BUF_SIZE
|
// COMP_OUT_BUF_SIZE must be >= 1 and <= OUT_BUF_SIZE
|
||||||
#define COMP_OUT_BUF_SIZE (1024*512)
|
#define COMP_OUT_BUF_SIZE (1024*512)
|
||||||
|
|
||||||
// OUT_BUF_SIZE is the size of the output buffer used during decompression.
|
// OUT_BUF_SIZE is the size of the output buffer used during decompression.
|
||||||
// OUT_BUF_SIZE must be a power of 2 >= TINFL_LZ_DICT_SIZE (because the low-level decompressor not only writes, but reads from the output buffer as it decompresses)
|
// OUT_BUF_SIZE must be a power of 2 >= TINFL_LZ_DICT_SIZE (because the low-level decompressor not only writes, but reads from the output buffer as it decompresses)
|
||||||
//#define OUT_BUF_SIZE (TINFL_LZ_DICT_SIZE)
|
//#define OUT_BUF_SIZE (TINFL_LZ_DICT_SIZE)
|
||||||
#define OUT_BUF_SIZE (1024*512)
|
#define OUT_BUF_SIZE (1024*512)
|
||||||
static uint8 s_outbuf[OUT_BUF_SIZE];
|
static uint8 s_outbuf[OUT_BUF_SIZE];
|
||||||
|
|
||||||
// tdefl_compressor contains all the state needed by the low-level compressor so it's a pretty big struct (~300k).
|
// tdefl_compressor contains all the state needed by the low-level compressor so it's a pretty big struct (~300k).
|
||||||
// This example makes it a global vs. putting it on the stack, of course in real-world usage you'll probably malloc() or new it.
|
// This example makes it a global vs. putting it on the stack, of course in real-world usage you'll probably malloc() or new it.
|
||||||
tdefl_compressor g_deflator;
|
tdefl_compressor g_deflator;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *pMode;
|
const char *pMode;
|
||||||
FILE *pInfile, *pOutfile;
|
FILE *pInfile, *pOutfile;
|
||||||
uint infile_size;
|
uint infile_size;
|
||||||
int level = 9;
|
int level = 9;
|
||||||
int p = 1;
|
int p = 1;
|
||||||
const char *pSrc_filename;
|
const char *pSrc_filename;
|
||||||
const char *pDst_filename;
|
const char *pDst_filename;
|
||||||
const void *next_in = s_inbuf;
|
const void *next_in = s_inbuf;
|
||||||
size_t avail_in = 0;
|
size_t avail_in = 0;
|
||||||
void *next_out = s_outbuf;
|
void *next_out = s_outbuf;
|
||||||
size_t avail_out = OUT_BUF_SIZE;
|
size_t avail_out = OUT_BUF_SIZE;
|
||||||
size_t total_in = 0, total_out = 0;
|
size_t total_in = 0, total_out = 0;
|
||||||
long file_loc;
|
long file_loc;
|
||||||
|
|
||||||
assert(COMP_OUT_BUF_SIZE <= OUT_BUF_SIZE);
|
assert(COMP_OUT_BUF_SIZE <= OUT_BUF_SIZE);
|
||||||
|
|
||||||
printf("miniz.c example5 (demonstrates tinfl/tdefl)\n");
|
printf("miniz.c example5 (demonstrates tinfl/tdefl)\n");
|
||||||
|
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
{
|
{
|
||||||
printf("File to file compression/decompression using the low-level tinfl/tdefl API's.\n");
|
printf("File to file compression/decompression using the low-level tinfl/tdefl API's.\n");
|
||||||
printf("Usage: example5 [options] [mode:c or d] infile outfile\n");
|
printf("Usage: example5 [options] [mode:c or d] infile outfile\n");
|
||||||
printf("\nModes:\n");
|
printf("\nModes:\n");
|
||||||
printf("c - Compresses file infile to a zlib stream in file outfile\n");
|
printf("c - Compresses file infile to a zlib stream in file outfile\n");
|
||||||
printf("d - Decompress zlib stream in file infile to file outfile\n");
|
printf("d - Decompress zlib stream in file infile to file outfile\n");
|
||||||
printf("\nOptions:\n");
|
printf("\nOptions:\n");
|
||||||
printf("-l[0-10] - Compression level, higher values are slower, 0 is none.\n");
|
printf("-l[0-10] - Compression level, higher values are slower, 0 is none.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((p < argc) && (argv[p][0] == '-'))
|
while ((p < argc) && (argv[p][0] == '-'))
|
||||||
{
|
{
|
||||||
switch (argv[p][1])
|
switch (argv[p][1])
|
||||||
{
|
{
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
level = atoi(&argv[1][2]);
|
level = atoi(&argv[1][2]);
|
||||||
if ((level < 0) || (level > 10))
|
if ((level < 0) || (level > 10))
|
||||||
{
|
{
|
||||||
printf("Invalid level!\n");
|
printf("Invalid level!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf("Invalid option: %s\n", argv[p]);
|
printf("Invalid option: %s\n", argv[p]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((argc - p) < 3)
|
if ((argc - p) < 3)
|
||||||
{
|
{
|
||||||
printf("Must specify mode, input filename, and output filename after options!\n");
|
printf("Must specify mode, input filename, and output filename after options!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else if ((argc - p) > 3)
|
else if ((argc - p) > 3)
|
||||||
{
|
{
|
||||||
printf("Too many filenames!\n");
|
printf("Too many filenames!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pMode = argv[p++];
|
pMode = argv[p++];
|
||||||
if (!strchr("cCdD", pMode[0]))
|
if (!strchr("cCdD", pMode[0]))
|
||||||
{
|
{
|
||||||
printf("Invalid mode!\n");
|
printf("Invalid mode!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSrc_filename = argv[p++];
|
pSrc_filename = argv[p++];
|
||||||
pDst_filename = argv[p++];
|
pDst_filename = argv[p++];
|
||||||
|
|
||||||
printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename);
|
printf("Mode: %c, Level: %u\nInput File: \"%s\"\nOutput File: \"%s\"\n", pMode[0], level, pSrc_filename, pDst_filename);
|
||||||
|
|
||||||
// Open input file.
|
// Open input file.
|
||||||
pInfile = fopen(pSrc_filename, "rb");
|
pInfile = fopen(pSrc_filename, "rb");
|
||||||
if (!pInfile)
|
if (!pInfile)
|
||||||
{
|
{
|
||||||
printf("Failed opening input file!\n");
|
printf("Failed opening input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine input file's size.
|
// Determine input file's size.
|
||||||
fseek(pInfile, 0, SEEK_END);
|
fseek(pInfile, 0, SEEK_END);
|
||||||
file_loc = ftell(pInfile);
|
file_loc = ftell(pInfile);
|
||||||
fseek(pInfile, 0, SEEK_SET);
|
fseek(pInfile, 0, SEEK_SET);
|
||||||
|
|
||||||
if ((file_loc < 0) || (file_loc > INT_MAX))
|
if ((file_loc < 0) || (file_loc > INT_MAX))
|
||||||
{
|
{
|
||||||
// This is not a limitation of miniz or tinfl, but this example.
|
// This is not a limitation of miniz or tinfl, but this example.
|
||||||
printf("File is too large to be processed by this example.\n");
|
printf("File is too large to be processed by this example.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
infile_size = (uint)file_loc;
|
infile_size = (uint)file_loc;
|
||||||
|
|
||||||
// Open output file.
|
// Open output file.
|
||||||
pOutfile = fopen(pDst_filename, "wb");
|
pOutfile = fopen(pDst_filename, "wb");
|
||||||
if (!pOutfile)
|
if (!pOutfile)
|
||||||
{
|
{
|
||||||
printf("Failed opening output file!\n");
|
printf("Failed opening output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Input file size: %u\n", infile_size);
|
printf("Input file size: %u\n", infile_size);
|
||||||
|
|
||||||
if ((pMode[0] == 'c') || (pMode[0] == 'C'))
|
if ((pMode[0] == 'c') || (pMode[0] == 'C'))
|
||||||
{
|
{
|
||||||
// The number of dictionary probes to use at each compression level (0-10). 0=implies fastest/minimal possible probing.
|
// The number of dictionary probes to use at each compression level (0-10). 0=implies fastest/minimal possible probing.
|
||||||
static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
|
static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
|
||||||
|
|
||||||
tdefl_status status;
|
tdefl_status status;
|
||||||
uint infile_remaining = infile_size;
|
uint infile_remaining = infile_size;
|
||||||
|
|
||||||
// create tdefl() compatible flags (we have to compose the low-level flags ourselves, or use tdefl_create_comp_flags_from_zip_params() but that means MINIZ_NO_ZLIB_APIS can't be defined).
|
// create tdefl() compatible flags (we have to compose the low-level flags ourselves, or use tdefl_create_comp_flags_from_zip_params() but that means MINIZ_NO_ZLIB_APIS can't be defined).
|
||||||
mz_uint comp_flags = TDEFL_WRITE_ZLIB_HEADER | s_tdefl_num_probes[MZ_MIN(10, level)] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0);
|
mz_uint comp_flags = TDEFL_WRITE_ZLIB_HEADER | s_tdefl_num_probes[MZ_MIN(10, level)] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0);
|
||||||
if (!level)
|
if (!level)
|
||||||
comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS;
|
comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS;
|
||||||
|
|
||||||
// Initialize the low-level compressor.
|
// Initialize the low-level compressor.
|
||||||
status = tdefl_init(&g_deflator, NULL, NULL, comp_flags);
|
status = tdefl_init(&g_deflator, NULL, NULL, comp_flags);
|
||||||
if (status != TDEFL_STATUS_OKAY)
|
if (status != TDEFL_STATUS_OKAY)
|
||||||
{
|
{
|
||||||
printf("tdefl_init() failed!\n");
|
printf("tdefl_init() failed!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
avail_out = COMP_OUT_BUF_SIZE;
|
avail_out = COMP_OUT_BUF_SIZE;
|
||||||
|
|
||||||
// Compression.
|
// Compression.
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
size_t in_bytes, out_bytes;
|
size_t in_bytes, out_bytes;
|
||||||
|
|
||||||
if (!avail_in)
|
if (!avail_in)
|
||||||
{
|
{
|
||||||
// Input buffer is empty, so read more bytes from input file.
|
// Input buffer is empty, so read more bytes from input file.
|
||||||
uint n = my_min(IN_BUF_SIZE, infile_remaining);
|
uint n = my_min(IN_BUF_SIZE, infile_remaining);
|
||||||
|
|
||||||
if (fread(s_inbuf, 1, n, pInfile) != n)
|
if (fread(s_inbuf, 1, n, pInfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed reading from input file!\n");
|
printf("Failed reading from input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
next_in = s_inbuf;
|
next_in = s_inbuf;
|
||||||
avail_in = n;
|
avail_in = n;
|
||||||
|
|
||||||
infile_remaining -= n;
|
infile_remaining -= n;
|
||||||
//printf("Input bytes remaining: %u\n", infile_remaining);
|
//printf("Input bytes remaining: %u\n", infile_remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
in_bytes = avail_in;
|
in_bytes = avail_in;
|
||||||
out_bytes = avail_out;
|
out_bytes = avail_out;
|
||||||
// Compress as much of the input as possible (or all of it) to the output buffer.
|
// Compress as much of the input as possible (or all of it) to the output buffer.
|
||||||
status = tdefl_compress(&g_deflator, next_in, &in_bytes, next_out, &out_bytes, infile_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH);
|
status = tdefl_compress(&g_deflator, next_in, &in_bytes, next_out, &out_bytes, infile_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH);
|
||||||
|
|
||||||
next_in = (const char *)next_in + in_bytes;
|
next_in = (const char *)next_in + in_bytes;
|
||||||
avail_in -= in_bytes;
|
avail_in -= in_bytes;
|
||||||
total_in += in_bytes;
|
total_in += in_bytes;
|
||||||
|
|
||||||
next_out = (char *)next_out + out_bytes;
|
next_out = (char *)next_out + out_bytes;
|
||||||
avail_out -= out_bytes;
|
avail_out -= out_bytes;
|
||||||
total_out += out_bytes;
|
total_out += out_bytes;
|
||||||
|
|
||||||
if ((status != TDEFL_STATUS_OKAY) || (!avail_out))
|
if ((status != TDEFL_STATUS_OKAY) || (!avail_out))
|
||||||
{
|
{
|
||||||
// Output buffer is full, or compression is done or failed, so write buffer to output file.
|
// Output buffer is full, or compression is done or failed, so write buffer to output file.
|
||||||
uint n = COMP_OUT_BUF_SIZE - (uint)avail_out;
|
uint n = COMP_OUT_BUF_SIZE - (uint)avail_out;
|
||||||
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
next_out = s_outbuf;
|
next_out = s_outbuf;
|
||||||
avail_out = COMP_OUT_BUF_SIZE;
|
avail_out = COMP_OUT_BUF_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == TDEFL_STATUS_DONE)
|
if (status == TDEFL_STATUS_DONE)
|
||||||
{
|
{
|
||||||
// Compression completed successfully.
|
// Compression completed successfully.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (status != TDEFL_STATUS_OKAY)
|
else if (status != TDEFL_STATUS_OKAY)
|
||||||
{
|
{
|
||||||
// Compression somehow failed.
|
// Compression somehow failed.
|
||||||
printf("tdefl_compress() failed with status %i!\n", status);
|
printf("tdefl_compress() failed with status %i!\n", status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((pMode[0] == 'd') || (pMode[0] == 'D'))
|
else if ((pMode[0] == 'd') || (pMode[0] == 'D'))
|
||||||
{
|
{
|
||||||
// Decompression.
|
// Decompression.
|
||||||
uint infile_remaining = infile_size;
|
uint infile_remaining = infile_size;
|
||||||
|
|
||||||
tinfl_decompressor inflator;
|
tinfl_decompressor inflator;
|
||||||
tinfl_init(&inflator);
|
tinfl_init(&inflator);
|
||||||
|
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
size_t in_bytes, out_bytes;
|
size_t in_bytes, out_bytes;
|
||||||
tinfl_status status;
|
tinfl_status status;
|
||||||
if (!avail_in)
|
if (!avail_in)
|
||||||
{
|
{
|
||||||
// Input buffer is empty, so read more bytes from input file.
|
// Input buffer is empty, so read more bytes from input file.
|
||||||
uint n = my_min(IN_BUF_SIZE, infile_remaining);
|
uint n = my_min(IN_BUF_SIZE, infile_remaining);
|
||||||
|
|
||||||
if (fread(s_inbuf, 1, n, pInfile) != n)
|
if (fread(s_inbuf, 1, n, pInfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed reading from input file!\n");
|
printf("Failed reading from input file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
next_in = s_inbuf;
|
next_in = s_inbuf;
|
||||||
avail_in = n;
|
avail_in = n;
|
||||||
|
|
||||||
infile_remaining -= n;
|
infile_remaining -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_bytes = avail_in;
|
in_bytes = avail_in;
|
||||||
out_bytes = avail_out;
|
out_bytes = avail_out;
|
||||||
status = tinfl_decompress(&inflator, (const mz_uint8 *)next_in, &in_bytes, s_outbuf, (mz_uint8 *)next_out, &out_bytes, (infile_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0) | TINFL_FLAG_PARSE_ZLIB_HEADER);
|
status = tinfl_decompress(&inflator, (const mz_uint8 *)next_in, &in_bytes, s_outbuf, (mz_uint8 *)next_out, &out_bytes, (infile_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0) | TINFL_FLAG_PARSE_ZLIB_HEADER);
|
||||||
|
|
||||||
avail_in -= in_bytes;
|
avail_in -= in_bytes;
|
||||||
next_in = (const mz_uint8 *)next_in + in_bytes;
|
next_in = (const mz_uint8 *)next_in + in_bytes;
|
||||||
total_in += in_bytes;
|
total_in += in_bytes;
|
||||||
|
|
||||||
avail_out -= out_bytes;
|
avail_out -= out_bytes;
|
||||||
next_out = (mz_uint8 *)next_out + out_bytes;
|
next_out = (mz_uint8 *)next_out + out_bytes;
|
||||||
total_out += out_bytes;
|
total_out += out_bytes;
|
||||||
|
|
||||||
if ((status <= TINFL_STATUS_DONE) || (!avail_out))
|
if ((status <= TINFL_STATUS_DONE) || (!avail_out))
|
||||||
{
|
{
|
||||||
// Output buffer is full, or decompression is done, so write buffer to output file.
|
// Output buffer is full, or decompression is done, so write buffer to output file.
|
||||||
uint n = OUT_BUF_SIZE - (uint)avail_out;
|
uint n = OUT_BUF_SIZE - (uint)avail_out;
|
||||||
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
if (fwrite(s_outbuf, 1, n, pOutfile) != n)
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
next_out = s_outbuf;
|
next_out = s_outbuf;
|
||||||
avail_out = OUT_BUF_SIZE;
|
avail_out = OUT_BUF_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If status is <= TINFL_STATUS_DONE then either decompression is done or something went wrong.
|
// If status is <= TINFL_STATUS_DONE then either decompression is done or something went wrong.
|
||||||
if (status <= TINFL_STATUS_DONE)
|
if (status <= TINFL_STATUS_DONE)
|
||||||
{
|
{
|
||||||
if (status == TINFL_STATUS_DONE)
|
if (status == TINFL_STATUS_DONE)
|
||||||
{
|
{
|
||||||
// Decompression completed successfully.
|
// Decompression completed successfully.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Decompression failed.
|
// Decompression failed.
|
||||||
printf("tinfl_decompress() failed with status %i!\n", status);
|
printf("tinfl_decompress() failed with status %i!\n", status);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Invalid mode!\n");
|
printf("Invalid mode!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(pInfile);
|
fclose(pInfile);
|
||||||
if (EOF == fclose(pOutfile))
|
if (EOF == fclose(pOutfile))
|
||||||
{
|
{
|
||||||
printf("Failed writing to output file!\n");
|
printf("Failed writing to output file!\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Total input bytes: %u\n", (mz_uint32)total_in);
|
printf("Total input bytes: %u\n", (mz_uint32)total_in);
|
||||||
printf("Total output bytes: %u\n", (mz_uint32)total_out);
|
printf("Total output bytes: %u\n", (mz_uint32)total_out);
|
||||||
printf("Success.\n");
|
printf("Success.\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+346
-346
@@ -1,346 +1,346 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="example5"
|
Name="example5"
|
||||||
ProjectGUID="{AE293522-92D8-4B60-95C7-B4AEE10A303F}"
|
ProjectGUID="{AE293522-92D8-4B60-95C7-B4AEE10A303F}"
|
||||||
RootNamespace="example5"
|
RootNamespace="example5"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="196613"
|
TargetFrameworkVersion="196613"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
<Platform
|
<Platform
|
||||||
Name="x64"
|
Name="x64"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A31F}"
|
UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A31F}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\example5.c"
|
RelativePath=".\example5.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAC02}"
|
UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAC02}"
|
||||||
>
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
+163
-163
@@ -1,163 +1,163 @@
|
|||||||
// example6.c - Demonstrates how to miniz's PNG writer func
|
// example6.c - Demonstrates how to miniz's PNG writer func
|
||||||
// Public domain, April 11 2012, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
// Public domain, April 11 2012, Rich Geldreich, richgel99@gmail.com. See "unlicense" statement at the end of tinfl.c.
|
||||||
// Mandlebrot set code from http://rosettacode.org/wiki/Mandelbrot_set#C
|
// Mandlebrot set code from http://rosettacode.org/wiki/Mandelbrot_set#C
|
||||||
// Must link this example against libm on Linux.
|
// Must link this example against libm on Linux.
|
||||||
|
|
||||||
// Purposely disable a whole bunch of stuff this low-level example doesn't use.
|
// Purposely disable a whole bunch of stuff this low-level example doesn't use.
|
||||||
#define MINIZ_NO_STDIO
|
#define MINIZ_NO_STDIO
|
||||||
#define MINIZ_NO_ARCHIVE_APIS
|
#define MINIZ_NO_ARCHIVE_APIS
|
||||||
#define MINIZ_NO_TIME
|
#define MINIZ_NO_TIME
|
||||||
#define MINIZ_NO_ZLIB_APIS
|
#define MINIZ_NO_ZLIB_APIS
|
||||||
#include "miniz.c"
|
#include "miniz.c"
|
||||||
|
|
||||||
// Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing).
|
// Now include stdio.h because this test uses fopen(), etc. (but we still don't want miniz.c's stdio stuff, for testing).
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8 r, g, b;
|
uint8 r, g, b;
|
||||||
} rgb_t;
|
} rgb_t;
|
||||||
|
|
||||||
static void hsv_to_rgb(int hue, int min, int max, rgb_t *p)
|
static void hsv_to_rgb(int hue, int min, int max, rgb_t *p)
|
||||||
{
|
{
|
||||||
const int invert = 0;
|
const int invert = 0;
|
||||||
const int saturation = 1;
|
const int saturation = 1;
|
||||||
const int color_rotate = 0;
|
const int color_rotate = 0;
|
||||||
|
|
||||||
if (min == max) max = min + 1;
|
if (min == max) max = min + 1;
|
||||||
if (invert) hue = max - (hue - min);
|
if (invert) hue = max - (hue - min);
|
||||||
if (!saturation) {
|
if (!saturation) {
|
||||||
p->r = p->g = p->b = 255 * (max - hue) / (max - min);
|
p->r = p->g = p->b = 255 * (max - hue) / (max - min);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double h = fmod(color_rotate + 1e-4 + 4.0 * (hue - min) / (max - min), 6);
|
double h = fmod(color_rotate + 1e-4 + 4.0 * (hue - min) / (max - min), 6);
|
||||||
double c = 255.0f * saturation;
|
double c = 255.0f * saturation;
|
||||||
double X = c * (1 - fabs(fmod(h, 2) - 1));
|
double X = c * (1 - fabs(fmod(h, 2) - 1));
|
||||||
|
|
||||||
p->r = p->g = p->b = 0;
|
p->r = p->g = p->b = 0;
|
||||||
|
|
||||||
switch((int)h) {
|
switch((int)h) {
|
||||||
case 0: p->r = c; p->g = X; return;
|
case 0: p->r = c; p->g = X; return;
|
||||||
case 1: p->r = X; p->g = c; return;
|
case 1: p->r = X; p->g = c; return;
|
||||||
case 2: p->g = c; p->b = X; return;
|
case 2: p->g = c; p->b = X; return;
|
||||||
case 3: p->g = X; p->b = c; return;
|
case 3: p->g = X; p->b = c; return;
|
||||||
case 4: p->r = X; p->b = c; return;
|
case 4: p->r = X; p->b = c; return;
|
||||||
default:p->r = c; p->b = X;
|
default:p->r = c; p->b = X;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
(void)argc, (void)argv;
|
(void)argc, (void)argv;
|
||||||
|
|
||||||
// Image resolution
|
// Image resolution
|
||||||
const int iXmax = 4096;
|
const int iXmax = 4096;
|
||||||
const int iYmax = 4096;
|
const int iYmax = 4096;
|
||||||
|
|
||||||
// Output filename
|
// Output filename
|
||||||
static const char *pFilename = "mandelbrot.png";
|
static const char *pFilename = "mandelbrot.png";
|
||||||
|
|
||||||
int iX, iY;
|
int iX, iY;
|
||||||
const double CxMin = -2.5;
|
const double CxMin = -2.5;
|
||||||
const double CxMax = 1.5;
|
const double CxMax = 1.5;
|
||||||
const double CyMin = -2.0;
|
const double CyMin = -2.0;
|
||||||
const double CyMax = 2.0;
|
const double CyMax = 2.0;
|
||||||
|
|
||||||
double PixelWidth = (CxMax - CxMin) / iXmax;
|
double PixelWidth = (CxMax - CxMin) / iXmax;
|
||||||
double PixelHeight = (CyMax - CyMin) / iYmax;
|
double PixelHeight = (CyMax - CyMin) / iYmax;
|
||||||
|
|
||||||
// Z=Zx+Zy*i ; Z0 = 0
|
// Z=Zx+Zy*i ; Z0 = 0
|
||||||
double Zx, Zy;
|
double Zx, Zy;
|
||||||
double Zx2, Zy2; // Zx2=Zx*Zx; Zy2=Zy*Zy
|
double Zx2, Zy2; // Zx2=Zx*Zx; Zy2=Zy*Zy
|
||||||
|
|
||||||
int Iteration;
|
int Iteration;
|
||||||
const int IterationMax = 200;
|
const int IterationMax = 200;
|
||||||
|
|
||||||
// bail-out value , radius of circle
|
// bail-out value , radius of circle
|
||||||
const double EscapeRadius = 2;
|
const double EscapeRadius = 2;
|
||||||
double ER2=EscapeRadius * EscapeRadius;
|
double ER2=EscapeRadius * EscapeRadius;
|
||||||
|
|
||||||
uint8 *pImage = (uint8 *)malloc(iXmax * 3 * iYmax);
|
uint8 *pImage = (uint8 *)malloc(iXmax * 3 * iYmax);
|
||||||
|
|
||||||
// world ( double) coordinate = parameter plane
|
// world ( double) coordinate = parameter plane
|
||||||
double Cx,Cy;
|
double Cx,Cy;
|
||||||
|
|
||||||
int MinIter = 9999, MaxIter = 0;
|
int MinIter = 9999, MaxIter = 0;
|
||||||
|
|
||||||
for(iY = 0; iY < iYmax; iY++)
|
for(iY = 0; iY < iYmax; iY++)
|
||||||
{
|
{
|
||||||
Cy = CyMin + iY * PixelHeight;
|
Cy = CyMin + iY * PixelHeight;
|
||||||
if (fabs(Cy) < PixelHeight/2)
|
if (fabs(Cy) < PixelHeight/2)
|
||||||
Cy = 0.0; // Main antenna
|
Cy = 0.0; // Main antenna
|
||||||
|
|
||||||
for(iX = 0; iX < iXmax; iX++)
|
for(iX = 0; iX < iXmax; iX++)
|
||||||
{
|
{
|
||||||
uint8 *color = pImage + (iX * 3) + (iY * iXmax * 3);
|
uint8 *color = pImage + (iX * 3) + (iY * iXmax * 3);
|
||||||
|
|
||||||
Cx = CxMin + iX * PixelWidth;
|
Cx = CxMin + iX * PixelWidth;
|
||||||
|
|
||||||
// initial value of orbit = critical point Z= 0
|
// initial value of orbit = critical point Z= 0
|
||||||
Zx = 0.0;
|
Zx = 0.0;
|
||||||
Zy = 0.0;
|
Zy = 0.0;
|
||||||
Zx2 = Zx * Zx;
|
Zx2 = Zx * Zx;
|
||||||
Zy2 = Zy * Zy;
|
Zy2 = Zy * Zy;
|
||||||
|
|
||||||
for (Iteration=0;Iteration<IterationMax && ((Zx2+Zy2)<ER2);Iteration++)
|
for (Iteration=0;Iteration<IterationMax && ((Zx2+Zy2)<ER2);Iteration++)
|
||||||
{
|
{
|
||||||
Zy = 2 * Zx * Zy + Cy;
|
Zy = 2 * Zx * Zy + Cy;
|
||||||
Zx =Zx2 - Zy2 + Cx;
|
Zx =Zx2 - Zy2 + Cx;
|
||||||
Zx2 = Zx * Zx;
|
Zx2 = Zx * Zx;
|
||||||
Zy2 = Zy * Zy;
|
Zy2 = Zy * Zy;
|
||||||
};
|
};
|
||||||
|
|
||||||
color[0] = (uint8)Iteration;
|
color[0] = (uint8)Iteration;
|
||||||
color[1] = (uint8)Iteration >> 8;
|
color[1] = (uint8)Iteration >> 8;
|
||||||
color[2] = 0;
|
color[2] = 0;
|
||||||
|
|
||||||
if (Iteration < MinIter)
|
if (Iteration < MinIter)
|
||||||
MinIter = Iteration;
|
MinIter = Iteration;
|
||||||
if (Iteration > MaxIter)
|
if (Iteration > MaxIter)
|
||||||
MaxIter = Iteration;
|
MaxIter = Iteration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(iY = 0; iY < iYmax; iY++)
|
for(iY = 0; iY < iYmax; iY++)
|
||||||
{
|
{
|
||||||
for(iX = 0; iX < iXmax; iX++)
|
for(iX = 0; iX < iXmax; iX++)
|
||||||
{
|
{
|
||||||
uint8 *color = (uint8 *)(pImage + (iX * 3) + (iY * iXmax * 3));
|
uint8 *color = (uint8 *)(pImage + (iX * 3) + (iY * iXmax * 3));
|
||||||
|
|
||||||
uint Iterations = color[0] | (color[1] << 8U);
|
uint Iterations = color[0] | (color[1] << 8U);
|
||||||
|
|
||||||
hsv_to_rgb(Iterations, MinIter, MaxIter, (rgb_t *)color);
|
hsv_to_rgb(Iterations, MinIter, MaxIter, (rgb_t *)color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now write the PNG image.
|
// Now write the PNG image.
|
||||||
{
|
{
|
||||||
size_t png_data_size = 0;
|
size_t png_data_size = 0;
|
||||||
void *pPNG_data = tdefl_write_image_to_png_file_in_memory_ex(pImage, iXmax, iYmax, 3, &png_data_size, 6, MZ_FALSE);
|
void *pPNG_data = tdefl_write_image_to_png_file_in_memory_ex(pImage, iXmax, iYmax, 3, &png_data_size, 6, MZ_FALSE);
|
||||||
if (!pPNG_data)
|
if (!pPNG_data)
|
||||||
fprintf(stderr, "tdefl_write_image_to_png_file_in_memory_ex() failed!\n");
|
fprintf(stderr, "tdefl_write_image_to_png_file_in_memory_ex() failed!\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE *pFile = fopen(pFilename, "wb");
|
FILE *pFile = fopen(pFilename, "wb");
|
||||||
fwrite(pPNG_data, 1, png_data_size, pFile);
|
fwrite(pPNG_data, 1, png_data_size, pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
printf("Wrote %s\n", pFilename);
|
printf("Wrote %s\n", pFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mz_free() is by default just an alias to free() internally, but if you've overridden miniz's allocation funcs you'll probably need to call mz_free().
|
// mz_free() is by default just an alias to free() internally, but if you've overridden miniz's allocation funcs you'll probably need to call mz_free().
|
||||||
mz_free(pPNG_data);
|
mz_free(pPNG_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pImage);
|
free(pImage);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +1,76 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
# Visual Studio 2008
|
# Visual Studio 2008
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "example1.vcproj", "{BE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "example1.vcproj", "{BE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "example2.vcproj", "{AE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "example2.vcproj", "{AE273522-92D8-4B60-95C7-C3AEE10A303E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example3", "example3.vcproj", "{AE273522-92D8-4B60-95C7-C3AEE10A303F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example3", "example3.vcproj", "{AE273522-92D8-4B60-95C7-C3AEE10A303F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example4", "example4.vcproj", "{AE293522-92D8-4B60-95C7-C3AEE10A303F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example4", "example4.vcproj", "{AE293522-92D8-4B60-95C7-C3AEE10A303F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example5", "example5.vcproj", "{AE293522-92D8-4B60-95C7-B4AEE10A303F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example5", "example5.vcproj", "{AE293522-92D8-4B60-95C7-B4AEE10A303F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniz_tester", "miniz_tester.vcproj", "{AE293522-92D9-1B60-95C7-B4AEE10A303F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniz_tester", "miniz_tester.vcproj", "{AE293522-92D9-1B60-95C7-B4AEE10A303F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
Release|Win32 = Release|Win32
|
Release|Win32 = Release|Win32
|
||||||
Release|x64 = Release|x64
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.ActiveCfg = Debug|Win32
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.Build.0 = Debug|Win32
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.ActiveCfg = Debug|x64
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.Build.0 = Debug|x64
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.Build.0 = Debug|x64
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.ActiveCfg = Release|Win32
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.Build.0 = Release|Win32
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.Build.0 = Release|Win32
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.ActiveCfg = Release|x64
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.Build.0 = Release|x64
|
{BE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.Build.0 = Release|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.ActiveCfg = Debug|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.Build.0 = Debug|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.ActiveCfg = Debug|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.Build.0 = Debug|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.ActiveCfg = Release|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.Build.0 = Release|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|Win32.Build.0 = Release|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.ActiveCfg = Release|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.Build.0 = Release|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303E}.Release|x64.Build.0 = Release|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
||||||
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.Build.0 = Release|x64
|
{AE273522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.Build.0 = Release|x64
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
||||||
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.Build.0 = Release|x64
|
{AE293522-92D8-4B60-95C7-C3AEE10A303F}.Release|x64.Build.0 = Release|x64
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
||||||
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|x64.Build.0 = Release|x64
|
{AE293522-92D8-4B60-95C7-B4AEE10A303F}.Release|x64.Build.0 = Release|x64
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|Win32.Build.0 = Release|Win32
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|x64.ActiveCfg = Release|x64
|
||||||
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|x64.Build.0 = Release|x64
|
{AE293522-92D9-1B60-95C7-B4AEE10A303F}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
+4916
-4916
File diff suppressed because it is too large
Load Diff
+1809
-1809
File diff suppressed because it is too large
Load Diff
@@ -1,358 +1,358 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
Name="miniz_tester"
|
Name="miniz_tester"
|
||||||
ProjectGUID="{AE293522-92D9-1B60-95C7-B4AEE10A303F}"
|
ProjectGUID="{AE293522-92D9-1B60-95C7-B4AEE10A303F}"
|
||||||
RootNamespace="miniz_tester"
|
RootNamespace="miniz_tester"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
TargetFrameworkVersion="196613"
|
TargetFrameworkVersion="196613"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"
|
Name="Win32"
|
||||||
/>
|
/>
|
||||||
<Platform
|
<Platform
|
||||||
Name="x64"
|
Name="x64"
|
||||||
/>
|
/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<ToolFiles>
|
<ToolFiles>
|
||||||
</ToolFiles>
|
</ToolFiles>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|x64"
|
Name="Debug|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64D.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|x64"
|
Name="Release|x64"
|
||||||
OutputDirectory="$(SolutionDir)bin"
|
OutputDirectory="$(SolutionDir)bin"
|
||||||
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)_$(PlatformName)"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"
|
Name="VCPreBuildEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"
|
Name="VCCustomBuildTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"
|
Name="VCXMLDataGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"
|
Name="VCMIDLTool"
|
||||||
TargetEnvironment="3"
|
TargetEnvironment="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
Optimization="3"
|
||||||
InlineFunctionExpansion="2"
|
InlineFunctionExpansion="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedResourceCompilerTool"
|
Name="VCManagedResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"
|
Name="VCResourceCompilerTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
OutputFile="$(OutDir)\$(ProjectName)_x64.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="17"
|
TargetMachine="17"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCBscMakeTool"
|
Name="VCBscMakeTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAppVerifierTool"
|
Name="VCAppVerifierTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A31F}"
|
UniqueIdentifier="{4FD737F1-C7A5-4376-A066-2A32D752A31F}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\miniz.c"
|
RelativePath=".\miniz.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\miniz_tester.cpp"
|
RelativePath=".\miniz_tester.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\timer.cpp"
|
RelativePath=".\timer.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\timer.h"
|
RelativePath=".\timer.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAC02}"
|
UniqueIdentifier="{17DA6AB6-F800-4c08-8B7A-83BB121AAC02}"
|
||||||
>
|
>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
+152
-152
@@ -1,152 +1,152 @@
|
|||||||
// File: timer.cpp - Simple high-precision timer class. Supports Win32, X360, and POSIX/Linux
|
// File: timer.cpp - Simple high-precision timer class. Supports Win32, X360, and POSIX/Linux
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#elif defined(_XBOX)
|
#elif defined(_XBOX)
|
||||||
#include <xtl.h>
|
#include <xtl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned long long timer::g_init_ticks;
|
unsigned long long timer::g_init_ticks;
|
||||||
unsigned long long timer::g_freq;
|
unsigned long long timer::g_freq;
|
||||||
double timer::g_inv_freq;
|
double timer::g_inv_freq;
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_XBOX)
|
#if defined(WIN32) || defined(_XBOX)
|
||||||
inline void query_counter(timer_ticks *pTicks)
|
inline void query_counter(timer_ticks *pTicks)
|
||||||
{
|
{
|
||||||
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(pTicks));
|
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(pTicks));
|
||||||
}
|
}
|
||||||
inline void query_counter_frequency(timer_ticks *pTicks)
|
inline void query_counter_frequency(timer_ticks *pTicks)
|
||||||
{
|
{
|
||||||
QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(pTicks));
|
QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(pTicks));
|
||||||
}
|
}
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#include <sys/timex.h>
|
#include <sys/timex.h>
|
||||||
inline void query_counter(timer_ticks *pTicks)
|
inline void query_counter(timer_ticks *pTicks)
|
||||||
{
|
{
|
||||||
struct timeval cur_time;
|
struct timeval cur_time;
|
||||||
gettimeofday(&cur_time, NULL);
|
gettimeofday(&cur_time, NULL);
|
||||||
*pTicks = static_cast<unsigned long long>(cur_time.tv_sec)*1000000ULL + static_cast<unsigned long long>(cur_time.tv_usec);
|
*pTicks = static_cast<unsigned long long>(cur_time.tv_sec)*1000000ULL + static_cast<unsigned long long>(cur_time.tv_usec);
|
||||||
}
|
}
|
||||||
inline void query_counter_frequency(timer_ticks *pTicks)
|
inline void query_counter_frequency(timer_ticks *pTicks)
|
||||||
{
|
{
|
||||||
*pTicks = 1000000;
|
*pTicks = 1000000;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timer::timer() :
|
timer::timer() :
|
||||||
m_start_time(0),
|
m_start_time(0),
|
||||||
m_stop_time(0),
|
m_stop_time(0),
|
||||||
m_started(false),
|
m_started(false),
|
||||||
m_stopped(false)
|
m_stopped(false)
|
||||||
{
|
{
|
||||||
if (!g_inv_freq)
|
if (!g_inv_freq)
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
timer::timer(timer_ticks start_ticks)
|
timer::timer(timer_ticks start_ticks)
|
||||||
{
|
{
|
||||||
if (!g_inv_freq)
|
if (!g_inv_freq)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
m_start_time = start_ticks;
|
m_start_time = start_ticks;
|
||||||
|
|
||||||
m_started = true;
|
m_started = true;
|
||||||
m_stopped = false;
|
m_stopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer::start(timer_ticks start_ticks)
|
void timer::start(timer_ticks start_ticks)
|
||||||
{
|
{
|
||||||
m_start_time = start_ticks;
|
m_start_time = start_ticks;
|
||||||
|
|
||||||
m_started = true;
|
m_started = true;
|
||||||
m_stopped = false;
|
m_stopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer::start()
|
void timer::start()
|
||||||
{
|
{
|
||||||
query_counter(&m_start_time);
|
query_counter(&m_start_time);
|
||||||
|
|
||||||
m_started = true;
|
m_started = true;
|
||||||
m_stopped = false;
|
m_stopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer::stop()
|
void timer::stop()
|
||||||
{
|
{
|
||||||
assert(m_started);
|
assert(m_started);
|
||||||
|
|
||||||
query_counter(&m_stop_time);
|
query_counter(&m_stop_time);
|
||||||
|
|
||||||
m_stopped = true;
|
m_stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double timer::get_elapsed_secs() const
|
double timer::get_elapsed_secs() const
|
||||||
{
|
{
|
||||||
assert(m_started);
|
assert(m_started);
|
||||||
if (!m_started)
|
if (!m_started)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
timer_ticks stop_time = m_stop_time;
|
timer_ticks stop_time = m_stop_time;
|
||||||
if (!m_stopped)
|
if (!m_stopped)
|
||||||
query_counter(&stop_time);
|
query_counter(&stop_time);
|
||||||
|
|
||||||
timer_ticks delta = stop_time - m_start_time;
|
timer_ticks delta = stop_time - m_start_time;
|
||||||
return delta * g_inv_freq;
|
return delta * g_inv_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_ticks timer::get_elapsed_us() const
|
timer_ticks timer::get_elapsed_us() const
|
||||||
{
|
{
|
||||||
assert(m_started);
|
assert(m_started);
|
||||||
if (!m_started)
|
if (!m_started)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
timer_ticks stop_time = m_stop_time;
|
timer_ticks stop_time = m_stop_time;
|
||||||
if (!m_stopped)
|
if (!m_stopped)
|
||||||
query_counter(&stop_time);
|
query_counter(&stop_time);
|
||||||
|
|
||||||
timer_ticks delta = stop_time - m_start_time;
|
timer_ticks delta = stop_time - m_start_time;
|
||||||
return (delta * 1000000ULL + (g_freq >> 1U)) / g_freq;
|
return (delta * 1000000ULL + (g_freq >> 1U)) / g_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer::init()
|
void timer::init()
|
||||||
{
|
{
|
||||||
if (!g_inv_freq)
|
if (!g_inv_freq)
|
||||||
{
|
{
|
||||||
query_counter_frequency(&g_freq);
|
query_counter_frequency(&g_freq);
|
||||||
g_inv_freq = 1.0f / g_freq;
|
g_inv_freq = 1.0f / g_freq;
|
||||||
|
|
||||||
query_counter(&g_init_ticks);
|
query_counter(&g_init_ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_ticks timer::get_init_ticks()
|
timer_ticks timer::get_init_ticks()
|
||||||
{
|
{
|
||||||
if (!g_inv_freq)
|
if (!g_inv_freq)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
return g_init_ticks;
|
return g_init_ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_ticks timer::get_ticks()
|
timer_ticks timer::get_ticks()
|
||||||
{
|
{
|
||||||
if (!g_inv_freq)
|
if (!g_inv_freq)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
timer_ticks ticks;
|
timer_ticks ticks;
|
||||||
query_counter(&ticks);
|
query_counter(&ticks);
|
||||||
return ticks - g_init_ticks;
|
return ticks - g_init_ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
double timer::ticks_to_secs(timer_ticks ticks)
|
double timer::ticks_to_secs(timer_ticks ticks)
|
||||||
{
|
{
|
||||||
if (!g_inv_freq)
|
if (!g_inv_freq)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
return ticks * g_inv_freq;
|
return ticks * g_inv_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+40
-40
@@ -1,40 +1,40 @@
|
|||||||
// File: timer.h
|
// File: timer.h
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef unsigned long long timer_ticks;
|
typedef unsigned long long timer_ticks;
|
||||||
|
|
||||||
class timer
|
class timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
timer();
|
timer();
|
||||||
timer(timer_ticks start_ticks);
|
timer(timer_ticks start_ticks);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void start(timer_ticks start_ticks);
|
void start(timer_ticks start_ticks);
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
double get_elapsed_secs() const;
|
double get_elapsed_secs() const;
|
||||||
inline double get_elapsed_ms() const { return get_elapsed_secs() * 1000.0f; }
|
inline double get_elapsed_ms() const { return get_elapsed_secs() * 1000.0f; }
|
||||||
timer_ticks get_elapsed_us() const;
|
timer_ticks get_elapsed_us() const;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static inline timer_ticks get_ticks_per_sec() { return g_freq; }
|
static inline timer_ticks get_ticks_per_sec() { return g_freq; }
|
||||||
static timer_ticks get_init_ticks();
|
static timer_ticks get_init_ticks();
|
||||||
static timer_ticks get_ticks();
|
static timer_ticks get_ticks();
|
||||||
static double ticks_to_secs(timer_ticks ticks);
|
static double ticks_to_secs(timer_ticks ticks);
|
||||||
static inline double ticks_to_ms(timer_ticks ticks) { return ticks_to_secs(ticks) * 1000.0f; }
|
static inline double ticks_to_ms(timer_ticks ticks) { return ticks_to_secs(ticks) * 1000.0f; }
|
||||||
static inline double get_secs() { return ticks_to_secs(get_ticks()); }
|
static inline double get_secs() { return ticks_to_secs(get_ticks()); }
|
||||||
static inline double get_ms() { return ticks_to_ms(get_ticks()); }
|
static inline double get_ms() { return ticks_to_ms(get_ticks()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static timer_ticks g_init_ticks;
|
static timer_ticks g_init_ticks;
|
||||||
static timer_ticks g_freq;
|
static timer_ticks g_freq;
|
||||||
static double g_inv_freq;
|
static double g_inv_freq;
|
||||||
|
|
||||||
timer_ticks m_start_time;
|
timer_ticks m_start_time;
|
||||||
timer_ticks m_stop_time;
|
timer_ticks m_stop_time;
|
||||||
|
|
||||||
bool m_started : 1;
|
bool m_started : 1;
|
||||||
bool m_stopped : 1;
|
bool m_stopped : 1;
|
||||||
};
|
};
|
||||||
|
|||||||
+592
-592
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
|||||||
.build
|
.build
|
||||||
*.syms
|
*.syms
|
||||||
|
|||||||
+95
-95
@@ -1,95 +1,95 @@
|
|||||||
idf_build_get_property(target IDF_TARGET)
|
idf_build_get_property(target IDF_TARGET)
|
||||||
|
|
||||||
if(${target} STREQUAL "linux")
|
if(${target} STREQUAL "linux")
|
||||||
return() # This component is not supported by the POSIX/Linux simulator
|
return() # This component is not supported by the POSIX/Linux simulator
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(include_dirs "platform_include")
|
set(include_dirs "platform_include")
|
||||||
|
|
||||||
if(BOOTLOADER_BUILD)
|
if(BOOTLOADER_BUILD)
|
||||||
# Bootloader builds need the platform_include directory (for assert.h), but nothing else
|
# Bootloader builds need the platform_include directory (for assert.h), but nothing else
|
||||||
idf_component_register(INCLUDE_DIRS platform_include)
|
idf_component_register(INCLUDE_DIRS platform_include)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(srcs
|
set(srcs
|
||||||
"abort.c"
|
"abort.c"
|
||||||
"assert.c"
|
"assert.c"
|
||||||
"heap.c"
|
"heap.c"
|
||||||
"flockfile.c"
|
"flockfile.c"
|
||||||
"locks.c"
|
"locks.c"
|
||||||
"poll.c"
|
"poll.c"
|
||||||
"pthread.c"
|
"pthread.c"
|
||||||
"random.c"
|
"random.c"
|
||||||
"getentropy.c"
|
"getentropy.c"
|
||||||
"reent_init.c"
|
"reent_init.c"
|
||||||
"newlib_init.c"
|
"newlib_init.c"
|
||||||
"syscalls.c"
|
"syscalls.c"
|
||||||
"termios.c"
|
"termios.c"
|
||||||
"stdatomic.c"
|
"stdatomic.c"
|
||||||
"time.c"
|
"time.c"
|
||||||
"sysconf.c"
|
"sysconf.c"
|
||||||
"realpath.c"
|
"realpath.c"
|
||||||
"scandir.c"
|
"scandir.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
||||||
list(APPEND srcs "port/xtensa/stdatomic_s32c1i.c")
|
list(APPEND srcs "port/xtensa/stdatomic_s32c1i.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
||||||
set(ldfragments "esp32-spiram-rom-functions-c.lf")
|
set(ldfragments "esp32-spiram-rom-functions-c.lf")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND ldfragments "newlib.lf" "system_libs.lf")
|
list(APPEND ldfragments "newlib.lf" "system_libs.lf")
|
||||||
|
|
||||||
idf_component_register(SRCS "${srcs}"
|
idf_component_register(SRCS "${srcs}"
|
||||||
INCLUDE_DIRS "${include_dirs}"
|
INCLUDE_DIRS "${include_dirs}"
|
||||||
PRIV_INCLUDE_DIRS priv_include
|
PRIV_INCLUDE_DIRS priv_include
|
||||||
PRIV_REQUIRES soc spi_flash
|
PRIV_REQUIRES soc spi_flash
|
||||||
LDFRAGMENTS "${ldfragments}")
|
LDFRAGMENTS "${ldfragments}")
|
||||||
|
|
||||||
# Toolchain libraries require code defined in this component
|
# Toolchain libraries require code defined in this component
|
||||||
idf_component_get_property(newlib newlib COMPONENT_LIB)
|
idf_component_get_property(newlib newlib COMPONENT_LIB)
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE c m ${CONFIG_COMPILER_RT_LIB_NAME} "$<TARGET_FILE:${newlib}>")
|
target_link_libraries(${COMPONENT_LIB} INTERFACE c m ${CONFIG_COMPILER_RT_LIB_NAME} "$<TARGET_FILE:${newlib}>")
|
||||||
|
|
||||||
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
|
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
|
||||||
|
|
||||||
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
||||||
set_source_files_properties("port/xtensa/stdatomic_s32c1i.c"
|
set_source_files_properties("port/xtensa/stdatomic_s32c1i.c"
|
||||||
PROPERTIES COMPILE_FLAGS "-mno-disable-hardware-atomics")
|
PROPERTIES COMPILE_FLAGS "-mno-disable-hardware-atomics")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
|
# Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
|
||||||
# instead of the implementations provided by newlib.
|
# instead of the implementations provided by newlib.
|
||||||
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
|
||||||
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
|
||||||
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
|
||||||
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl")
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl")
|
||||||
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_getentropy_impl")
|
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_getentropy_impl")
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
|
||||||
|
|
||||||
# Forces the linker to include newlib_init.c
|
# Forces the linker to include newlib_init.c
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u newlib_include_init_funcs")
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u newlib_include_init_funcs")
|
||||||
|
|
||||||
if(CONFIG_NEWLIB_NANO_FORMAT)
|
if(CONFIG_NEWLIB_NANO_FORMAT)
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
set(libc_dir_cmd ${CMAKE_C_COMPILER})
|
set(libc_dir_cmd ${CMAKE_C_COMPILER})
|
||||||
string(REPLACE " " ";" cflags_list ${CMAKE_C_FLAGS})
|
string(REPLACE " " ";" cflags_list ${CMAKE_C_FLAGS})
|
||||||
list(APPEND libc_dir_cmd ${cflags_list} "-print-file-name=libc.a")
|
list(APPEND libc_dir_cmd ${cflags_list} "-print-file-name=libc.a")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${libc_dir_cmd}
|
COMMAND ${libc_dir_cmd}
|
||||||
OUTPUT_VARIABLE libc_dir
|
OUTPUT_VARIABLE libc_dir
|
||||||
)
|
)
|
||||||
get_filename_component(libc_dir ${libc_dir} DIRECTORY)
|
get_filename_component(libc_dir ${libc_dir} DIRECTORY)
|
||||||
target_link_directories(${COMPONENT_LIB} INTERFACE "${libc_dir}/nano")
|
target_link_directories(${COMPONENT_LIB} INTERFACE "${libc_dir}/nano")
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(port)
|
add_subdirectory(port)
|
||||||
|
|
||||||
# if lwip is included in the build, add it as a public requirement so that
|
# if lwip is included in the build, add it as a public requirement so that
|
||||||
# #include <sys/socket.h> works without any special provisions.
|
# #include <sys/socket.h> works without any special provisions.
|
||||||
idf_component_optional_requires(PUBLIC lwip)
|
idf_component_optional_requires(PUBLIC lwip)
|
||||||
|
|||||||
+952
-952
File diff suppressed because it is too large
Load Diff
+124
-124
@@ -1,124 +1,124 @@
|
|||||||
menu "Newlib"
|
menu "Newlib"
|
||||||
|
|
||||||
choice NEWLIB_STDOUT_LINE_ENDING
|
choice NEWLIB_STDOUT_LINE_ENDING
|
||||||
prompt "Line ending for UART output"
|
prompt "Line ending for UART output"
|
||||||
default NEWLIB_STDOUT_LINE_ENDING_CRLF
|
default NEWLIB_STDOUT_LINE_ENDING_CRLF
|
||||||
help
|
help
|
||||||
This option allows configuring the desired line endings sent to UART
|
This option allows configuring the desired line endings sent to UART
|
||||||
when a newline ('\n', LF) appears on stdout.
|
when a newline ('\n', LF) appears on stdout.
|
||||||
Three options are possible:
|
Three options are possible:
|
||||||
|
|
||||||
CRLF: whenever LF is encountered, prepend it with CR
|
CRLF: whenever LF is encountered, prepend it with CR
|
||||||
|
|
||||||
LF: no modification is applied, stdout is sent as is
|
LF: no modification is applied, stdout is sent as is
|
||||||
|
|
||||||
CR: each occurrence of LF is replaced with CR
|
CR: each occurrence of LF is replaced with CR
|
||||||
|
|
||||||
This option doesn't affect behavior of the UART driver (drivers/uart.h).
|
This option doesn't affect behavior of the UART driver (drivers/uart.h).
|
||||||
|
|
||||||
config NEWLIB_STDOUT_LINE_ENDING_CRLF
|
config NEWLIB_STDOUT_LINE_ENDING_CRLF
|
||||||
bool "CRLF"
|
bool "CRLF"
|
||||||
config NEWLIB_STDOUT_LINE_ENDING_LF
|
config NEWLIB_STDOUT_LINE_ENDING_LF
|
||||||
bool "LF"
|
bool "LF"
|
||||||
config NEWLIB_STDOUT_LINE_ENDING_CR
|
config NEWLIB_STDOUT_LINE_ENDING_CR
|
||||||
bool "CR"
|
bool "CR"
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
choice NEWLIB_STDIN_LINE_ENDING
|
choice NEWLIB_STDIN_LINE_ENDING
|
||||||
prompt "Line ending for UART input"
|
prompt "Line ending for UART input"
|
||||||
default NEWLIB_STDIN_LINE_ENDING_CR
|
default NEWLIB_STDIN_LINE_ENDING_CR
|
||||||
help
|
help
|
||||||
This option allows configuring which input sequence on UART produces
|
This option allows configuring which input sequence on UART produces
|
||||||
a newline ('\n', LF) on stdin.
|
a newline ('\n', LF) on stdin.
|
||||||
Three options are possible:
|
Three options are possible:
|
||||||
|
|
||||||
CRLF: CRLF is converted to LF
|
CRLF: CRLF is converted to LF
|
||||||
|
|
||||||
LF: no modification is applied, input is sent to stdin as is
|
LF: no modification is applied, input is sent to stdin as is
|
||||||
|
|
||||||
CR: each occurrence of CR is replaced with LF
|
CR: each occurrence of CR is replaced with LF
|
||||||
|
|
||||||
This option doesn't affect behavior of the UART driver (drivers/uart.h).
|
This option doesn't affect behavior of the UART driver (drivers/uart.h).
|
||||||
|
|
||||||
config NEWLIB_STDIN_LINE_ENDING_CRLF
|
config NEWLIB_STDIN_LINE_ENDING_CRLF
|
||||||
bool "CRLF"
|
bool "CRLF"
|
||||||
config NEWLIB_STDIN_LINE_ENDING_LF
|
config NEWLIB_STDIN_LINE_ENDING_LF
|
||||||
bool "LF"
|
bool "LF"
|
||||||
config NEWLIB_STDIN_LINE_ENDING_CR
|
config NEWLIB_STDIN_LINE_ENDING_CR
|
||||||
bool "CR"
|
bool "CR"
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config NEWLIB_NANO_FORMAT
|
config NEWLIB_NANO_FORMAT
|
||||||
bool "Enable 'nano' formatting options for printf/scanf family"
|
bool "Enable 'nano' formatting options for printf/scanf family"
|
||||||
default y if IDF_TARGET_ESP32C2
|
default y if IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
In most chips the ROM contains parts of newlib C library, including printf/scanf family
|
In most chips the ROM contains parts of newlib C library, including printf/scanf family
|
||||||
of functions. These functions have been compiled with so-called "nano"
|
of functions. These functions have been compiled with so-called "nano"
|
||||||
formatting option. This option doesn't support 64-bit integer formats and C99
|
formatting option. This option doesn't support 64-bit integer formats and C99
|
||||||
features, such as positional arguments.
|
features, such as positional arguments.
|
||||||
|
|
||||||
For more details about "nano" formatting option, please see newlib readme file,
|
For more details about "nano" formatting option, please see newlib readme file,
|
||||||
search for '--enable-newlib-nano-formatted-io':
|
search for '--enable-newlib-nano-formatted-io':
|
||||||
https://sourceware.org/git/?p=newlib-cygwin.git;a=blob_plain;f=newlib/README;hb=HEAD
|
https://sourceware.org/git/?p=newlib-cygwin.git;a=blob_plain;f=newlib/README;hb=HEAD
|
||||||
|
|
||||||
If this option is enabled and the ROM contains functions from newlib-nano, the build system
|
If this option is enabled and the ROM contains functions from newlib-nano, the build system
|
||||||
will use functions available in ROM, reducing the application binary size.
|
will use functions available in ROM, reducing the application binary size.
|
||||||
Functions available in ROM run faster than functions which run from flash. Functions available
|
Functions available in ROM run faster than functions which run from flash. Functions available
|
||||||
in ROM can also run when flash instruction cache is disabled.
|
in ROM can also run when flash instruction cache is disabled.
|
||||||
|
|
||||||
Some chips (e.g. ESP32-C6) has the full formatting versions of printf/scanf in ROM instead of
|
Some chips (e.g. ESP32-C6) has the full formatting versions of printf/scanf in ROM instead of
|
||||||
the nano versions and in this building with newlib nano might actually increase the size of
|
the nano versions and in this building with newlib nano might actually increase the size of
|
||||||
the binary. Which functions are present in ROM can be seen from ROM caps:
|
the binary. Which functions are present in ROM can be seen from ROM caps:
|
||||||
ESP_ROM_HAS_NEWLIB_NANO_FORMAT and ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT.
|
ESP_ROM_HAS_NEWLIB_NANO_FORMAT and ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT.
|
||||||
|
|
||||||
If you need 64-bit integer formatting support or C99 features, keep this
|
If you need 64-bit integer formatting support or C99 features, keep this
|
||||||
option disabled.
|
option disabled.
|
||||||
|
|
||||||
choice NEWLIB_TIME_SYSCALL
|
choice NEWLIB_TIME_SYSCALL
|
||||||
prompt "Timers used for gettimeofday function"
|
prompt "Timers used for gettimeofday function"
|
||||||
default NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
default NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
help
|
help
|
||||||
This setting defines which hardware timers are used to
|
This setting defines which hardware timers are used to
|
||||||
implement 'gettimeofday' and 'time' functions in C library.
|
implement 'gettimeofday' and 'time' functions in C library.
|
||||||
|
|
||||||
- If both high-resolution (systimer for all targets except ESP32)
|
- If both high-resolution (systimer for all targets except ESP32)
|
||||||
and RTC timers are used, timekeeping will continue in deep sleep.
|
and RTC timers are used, timekeeping will continue in deep sleep.
|
||||||
Time will be reported at 1 microsecond resolution.
|
Time will be reported at 1 microsecond resolution.
|
||||||
This is the default, and the recommended option.
|
This is the default, and the recommended option.
|
||||||
- If only high-resolution timer (systimer) is used, gettimeofday will
|
- If only high-resolution timer (systimer) is used, gettimeofday will
|
||||||
provide time at microsecond resolution.
|
provide time at microsecond resolution.
|
||||||
Time will not be preserved when going into deep sleep mode.
|
Time will not be preserved when going into deep sleep mode.
|
||||||
- If only RTC timer is used, timekeeping will continue in
|
- If only RTC timer is used, timekeeping will continue in
|
||||||
deep sleep, but time will be measured at 6.(6) microsecond
|
deep sleep, but time will be measured at 6.(6) microsecond
|
||||||
resolution. Also the gettimeofday function itself may take
|
resolution. Also the gettimeofday function itself may take
|
||||||
longer to run.
|
longer to run.
|
||||||
- If no timers are used, gettimeofday and time functions
|
- If no timers are used, gettimeofday and time functions
|
||||||
return -1 and set errno to ENOSYS; they are defined as weak,
|
return -1 and set errno to ENOSYS; they are defined as weak,
|
||||||
so they could be overridden.
|
so they could be overridden.
|
||||||
If you want to customize gettimeofday() and other time functions,
|
If you want to customize gettimeofday() and other time functions,
|
||||||
please choose this option and refer to the 'time.c' source file
|
please choose this option and refer to the 'time.c' source file
|
||||||
for the exact prototypes of these functions.
|
for the exact prototypes of these functions.
|
||||||
|
|
||||||
- When RTC is used for timekeeping, two RTC_STORE registers are
|
- When RTC is used for timekeeping, two RTC_STORE registers are
|
||||||
used to keep time in deep sleep mode.
|
used to keep time in deep sleep mode.
|
||||||
|
|
||||||
config NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
config NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
bool "RTC and high-resolution timer"
|
bool "RTC and high-resolution timer"
|
||||||
select ESP_TIME_FUNCS_USE_RTC_TIMER
|
select ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
select ESP_TIME_FUNCS_USE_ESP_TIMER
|
select ESP_TIME_FUNCS_USE_ESP_TIMER
|
||||||
config NEWLIB_TIME_SYSCALL_USE_RTC
|
config NEWLIB_TIME_SYSCALL_USE_RTC
|
||||||
bool "RTC"
|
bool "RTC"
|
||||||
select ESP_TIME_FUNCS_USE_RTC_TIMER
|
select ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
config NEWLIB_TIME_SYSCALL_USE_HRT
|
config NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
bool "High-resolution timer"
|
bool "High-resolution timer"
|
||||||
select ESP_TIME_FUNCS_USE_ESP_TIMER
|
select ESP_TIME_FUNCS_USE_ESP_TIMER
|
||||||
config NEWLIB_TIME_SYSCALL_USE_NONE
|
config NEWLIB_TIME_SYSCALL_USE_NONE
|
||||||
bool "None"
|
bool "None"
|
||||||
select ESP_TIME_FUNCS_USE_NONE
|
select ESP_TIME_FUNCS_USE_NONE
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
endmenu # Newlib
|
endmenu # Newlib
|
||||||
|
|
||||||
config STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
config STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
bool
|
bool
|
||||||
default SPIRAM && (IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3) && !IDF_TOOLCHAIN_CLANG # TODO IDF-9032
|
default SPIRAM && (IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3) && !IDF_TOOLCHAIN_CLANG # TODO IDF-9032
|
||||||
|
|||||||
+39
-39
@@ -1,39 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "esp_cpu.h"
|
#include "esp_cpu.h"
|
||||||
|
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
void __attribute__((noreturn)) abort(void)
|
void __attribute__((noreturn)) abort(void)
|
||||||
{
|
{
|
||||||
#define ERR_STR1 "abort() was called at PC 0x"
|
#define ERR_STR1 "abort() was called at PC 0x"
|
||||||
#define ERR_STR2 " on core "
|
#define ERR_STR2 " on core "
|
||||||
|
|
||||||
_Static_assert(UINTPTR_MAX == 0xffffffff, "abort() assumes 32-bit addresses");
|
_Static_assert(UINTPTR_MAX == 0xffffffff, "abort() assumes 32-bit addresses");
|
||||||
_Static_assert(SOC_CPU_CORES_NUM < 10, "abort() assumes number of cores is 1 to 9");
|
_Static_assert(SOC_CPU_CORES_NUM < 10, "abort() assumes number of cores is 1 to 9");
|
||||||
|
|
||||||
char addr_buf[9] = { 0 };
|
char addr_buf[9] = { 0 };
|
||||||
char core_buf[2] = { 0 };
|
char core_buf[2] = { 0 };
|
||||||
|
|
||||||
char buf[sizeof(ERR_STR1) + sizeof(addr_buf) + sizeof(core_buf) + sizeof(ERR_STR2) + 1 /* null char */] = { 0 };
|
char buf[sizeof(ERR_STR1) + sizeof(addr_buf) + sizeof(core_buf) + sizeof(ERR_STR2) + 1 /* null char */] = { 0 };
|
||||||
|
|
||||||
itoa((uint32_t)(__builtin_return_address(0) - 3), addr_buf, 16);
|
itoa((uint32_t)(__builtin_return_address(0) - 3), addr_buf, 16);
|
||||||
itoa(esp_cpu_get_core_id(), core_buf, 10);
|
itoa(esp_cpu_get_core_id(), core_buf, 10);
|
||||||
|
|
||||||
const char *str[] = { ERR_STR1, addr_buf, ERR_STR2, core_buf };
|
const char *str[] = { ERR_STR1, addr_buf, ERR_STR2, core_buf };
|
||||||
|
|
||||||
char *dest = buf;
|
char *dest = buf;
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(str) / sizeof(str[0]); i++) {
|
for (size_t i = 0; i < sizeof(str) / sizeof(str[0]); i++) {
|
||||||
strcat(dest, str[i]);
|
strcat(dest, str[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_system_abort(buf);
|
esp_system_abort(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
+92
-92
@@ -1,92 +1,92 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "soc/soc_memory_layout.h"
|
#include "soc/soc_memory_layout.h"
|
||||||
#include "esp_private/cache_utils.h"
|
#include "esp_private/cache_utils.h"
|
||||||
|
|
||||||
#define ASSERT_STR "assert failed: "
|
#define ASSERT_STR "assert failed: "
|
||||||
#define CACHE_DISABLED_STR "<cached disabled>"
|
#define CACHE_DISABLED_STR "<cached disabled>"
|
||||||
|
|
||||||
#if __XTENSA__
|
#if __XTENSA__
|
||||||
#define INST_LEN 3
|
#define INST_LEN 3
|
||||||
#elif __riscv
|
#elif __riscv
|
||||||
#define INST_LEN 4
|
#define INST_LEN 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void ra_to_str(char *addr)
|
static inline void ra_to_str(char *addr)
|
||||||
{
|
{
|
||||||
addr[0] = '0';
|
addr[0] = '0';
|
||||||
addr[1] = 'x';
|
addr[1] = 'x';
|
||||||
itoa((uint32_t)(__builtin_return_address(0) - INST_LEN), addr + 2, 16);
|
itoa((uint32_t)(__builtin_return_address(0) - INST_LEN), addr + 2, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Overriding assert function so that whenever assert is called from critical section,
|
/* Overriding assert function so that whenever assert is called from critical section,
|
||||||
* it does not lead to a crash of its own.
|
* it does not lead to a crash of its own.
|
||||||
*/
|
*/
|
||||||
void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *expr)
|
void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *expr)
|
||||||
{
|
{
|
||||||
#if CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
#if CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
||||||
char buff[sizeof(ASSERT_STR) + 11 + 1] = ASSERT_STR;
|
char buff[sizeof(ASSERT_STR) + 11 + 1] = ASSERT_STR;
|
||||||
|
|
||||||
ra_to_str(&buff[sizeof(ASSERT_STR) - 1]);
|
ra_to_str(&buff[sizeof(ASSERT_STR) - 1]);
|
||||||
|
|
||||||
esp_system_abort(buff);
|
esp_system_abort(buff);
|
||||||
#else
|
#else
|
||||||
char addr[11] = { 0 };
|
char addr[11] = { 0 };
|
||||||
char buff[200];
|
char buff[200];
|
||||||
char lbuf[5];
|
char lbuf[5];
|
||||||
uint32_t rem_len = sizeof(buff) - 1;
|
uint32_t rem_len = sizeof(buff) - 1;
|
||||||
uint32_t off = 0;
|
uint32_t off = 0;
|
||||||
|
|
||||||
itoa(line, lbuf, 10);
|
itoa(line, lbuf, 10);
|
||||||
|
|
||||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||||
if (!spi_flash_cache_enabled())
|
if (!spi_flash_cache_enabled())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (esp_ptr_in_drom(file)) {
|
if (esp_ptr_in_drom(file)) {
|
||||||
file = CACHE_DISABLED_STR;
|
file = CACHE_DISABLED_STR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esp_ptr_in_drom(func)) {
|
if (esp_ptr_in_drom(func)) {
|
||||||
ra_to_str(addr);
|
ra_to_str(addr);
|
||||||
func = addr;
|
func = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (esp_ptr_in_drom(expr)) {
|
if (esp_ptr_in_drom(expr)) {
|
||||||
expr = CACHE_DISABLED_STR;
|
expr = CACHE_DISABLED_STR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *str[] = {ASSERT_STR, func ? func : "\b", " ", file, ":", lbuf, " (", expr, ")"};
|
const char *str[] = {ASSERT_STR, func ? func : "\b", " ", file, ":", lbuf, " (", expr, ")"};
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(str) / sizeof(str[0]); i++) {
|
for (int i = 0; i < sizeof(str) / sizeof(str[0]); i++) {
|
||||||
uint32_t len = strlen(str[i]);
|
uint32_t len = strlen(str[i]);
|
||||||
uint32_t cpy_len = MIN(len, rem_len);
|
uint32_t cpy_len = MIN(len, rem_len);
|
||||||
memcpy(buff + off, str[i], cpy_len);
|
memcpy(buff + off, str[i], cpy_len);
|
||||||
rem_len -= cpy_len;
|
rem_len -= cpy_len;
|
||||||
off += cpy_len;
|
off += cpy_len;
|
||||||
if (rem_len == 0) {
|
if (rem_len == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buff[off] = '\0';
|
buff[off] = '\0';
|
||||||
esp_system_abort(buff);
|
esp_system_abort(buff);
|
||||||
#endif /* CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT */
|
#endif /* CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT */
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((noreturn)) __assert(const char *file, int line, const char *failedexpr)
|
void __attribute__((noreturn)) __assert(const char *file, int line, const char *failedexpr)
|
||||||
{
|
{
|
||||||
__assert_func(file, line, NULL, failedexpr);
|
__assert_func(file, line, NULL, failedexpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No-op function, used to force linker to include these changes */
|
/* No-op function, used to force linker to include these changes */
|
||||||
void newlib_include_assert_impl(void)
|
void newlib_include_assert_impl(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,171 +1,171 @@
|
|||||||
# If the Newlib functions in ROM aren't used (eg because the external SPI RAM workaround is active), these functions will
|
# If the Newlib functions in ROM aren't used (eg because the external SPI RAM workaround is active), these functions will
|
||||||
# be linked into the application directly instead. Normally, they would end up in flash, which is undesirable because esp-idf
|
# be linked into the application directly instead. Normally, they would end up in flash, which is undesirable because esp-idf
|
||||||
# and/or applications may assume that because these functions normally are in ROM, they are accessible even when flash is
|
# and/or applications may assume that because these functions normally are in ROM, they are accessible even when flash is
|
||||||
# inaccessible. To work around this, this ld fragment places these functions in RAM instead. If the ROM functions are used,
|
# inaccessible. To work around this, this ld fragment places these functions in RAM instead. If the ROM functions are used,
|
||||||
# these defines do nothing, so they can still be included in that situation.
|
# these defines do nothing, so they can still be included in that situation.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Note: the only difference between esp32-spiram-rom-functions-c.lf
|
# Note: the only difference between esp32-spiram-rom-functions-c.lf
|
||||||
# and esp32-spiram-rom-functions-psram-workaround.lf is the archive name.
|
# and esp32-spiram-rom-functions-psram-workaround.lf is the archive name.
|
||||||
|
|
||||||
[mapping:libc]
|
[mapping:libc]
|
||||||
archive:
|
archive:
|
||||||
if NEWLIB_NANO_FORMAT = y:
|
if NEWLIB_NANO_FORMAT = y:
|
||||||
libc_nano.a
|
libc_nano.a
|
||||||
else:
|
else:
|
||||||
libc.a
|
libc.a
|
||||||
entries:
|
entries:
|
||||||
if SPIRAM_CACHE_WORKAROUND = y:
|
if SPIRAM_CACHE_WORKAROUND = y:
|
||||||
# The following libs are either used in a lot of places or in critical
|
# The following libs are either used in a lot of places or in critical
|
||||||
# code. (such as panic or abort)
|
# code. (such as panic or abort)
|
||||||
# Thus, they shall always be placed in IRAM.
|
# Thus, they shall always be placed in IRAM.
|
||||||
libc_a-itoa (noflash)
|
libc_a-itoa (noflash)
|
||||||
libc_a-memcmp (noflash)
|
libc_a-memcmp (noflash)
|
||||||
libc_a-memcpy (noflash)
|
libc_a-memcpy (noflash)
|
||||||
libc_a-memset (noflash)
|
libc_a-memset (noflash)
|
||||||
libc_a-strcat (noflash)
|
libc_a-strcat (noflash)
|
||||||
libc_a-strcmp (noflash)
|
libc_a-strcmp (noflash)
|
||||||
libc_a-strlen (noflash)
|
libc_a-strlen (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBJMP_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBJMP_IN_IRAM = y:
|
||||||
libc_a-longjmp (noflash)
|
libc_a-longjmp (noflash)
|
||||||
libc_a-setjmp (noflash)
|
libc_a-setjmp (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBMATH_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBMATH_IN_IRAM = y:
|
||||||
libc_a-abs (noflash)
|
libc_a-abs (noflash)
|
||||||
libc_a-div (noflash)
|
libc_a-div (noflash)
|
||||||
libc_a-labs (noflash)
|
libc_a-labs (noflash)
|
||||||
libc_a-ldiv (noflash)
|
libc_a-ldiv (noflash)
|
||||||
libc_a-quorem (noflash)
|
libc_a-quorem (noflash)
|
||||||
libc_a-s_fpclassify (noflash)
|
libc_a-s_fpclassify (noflash)
|
||||||
libc_a-sf_nan (noflash)
|
libc_a-sf_nan (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBNUMPARSER_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBNUMPARSER_IN_IRAM = y:
|
||||||
libc_a-utoa (noflash)
|
libc_a-utoa (noflash)
|
||||||
libc_a-atoi (noflash)
|
libc_a-atoi (noflash)
|
||||||
libc_a-atol (noflash)
|
libc_a-atol (noflash)
|
||||||
libc_a-strtol (noflash)
|
libc_a-strtol (noflash)
|
||||||
libc_a-strtoul (noflash)
|
libc_a-strtoul (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBIO_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBIO_IN_IRAM = y:
|
||||||
libc_a-wcrtomb (noflash)
|
libc_a-wcrtomb (noflash)
|
||||||
libc_a-fvwrite (noflash)
|
libc_a-fvwrite (noflash)
|
||||||
libc_a-wbuf (noflash)
|
libc_a-wbuf (noflash)
|
||||||
libc_a-wsetup (noflash)
|
libc_a-wsetup (noflash)
|
||||||
libc_a-fputwc (noflash)
|
libc_a-fputwc (noflash)
|
||||||
libc_a-wctomb_r (noflash)
|
libc_a-wctomb_r (noflash)
|
||||||
libc_a-ungetc (noflash)
|
libc_a-ungetc (noflash)
|
||||||
libc_a-makebuf (noflash)
|
libc_a-makebuf (noflash)
|
||||||
libc_a-fflush (noflash)
|
libc_a-fflush (noflash)
|
||||||
libc_a-refill (noflash)
|
libc_a-refill (noflash)
|
||||||
libc_a-sccl (noflash)
|
libc_a-sccl (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBTIME_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBTIME_IN_IRAM = y:
|
||||||
libc_a-asctime (noflash)
|
libc_a-asctime (noflash)
|
||||||
libc_a-asctime_r (noflash)
|
libc_a-asctime_r (noflash)
|
||||||
libc_a-ctime (noflash)
|
libc_a-ctime (noflash)
|
||||||
libc_a-ctime_r (noflash)
|
libc_a-ctime_r (noflash)
|
||||||
libc_a-lcltime (noflash)
|
libc_a-lcltime (noflash)
|
||||||
libc_a-lcltime_r (noflash)
|
libc_a-lcltime_r (noflash)
|
||||||
libc_a-gmtime (noflash)
|
libc_a-gmtime (noflash)
|
||||||
libc_a-gmtime_r (noflash)
|
libc_a-gmtime_r (noflash)
|
||||||
libc_a-strftime (noflash)
|
libc_a-strftime (noflash)
|
||||||
libc_a-mktime (noflash)
|
libc_a-mktime (noflash)
|
||||||
libc_a-tzset_r (noflash)
|
libc_a-tzset_r (noflash)
|
||||||
libc_a-tzset (noflash)
|
libc_a-tzset (noflash)
|
||||||
libc_a-time (noflash)
|
libc_a-time (noflash)
|
||||||
libc_a-gettzinfo (noflash)
|
libc_a-gettzinfo (noflash)
|
||||||
libc_a-systimes (noflash)
|
libc_a-systimes (noflash)
|
||||||
libc_a-month_lengths (noflash)
|
libc_a-month_lengths (noflash)
|
||||||
libc_a-timelocal (noflash)
|
libc_a-timelocal (noflash)
|
||||||
libc_a-tzvars (noflash)
|
libc_a-tzvars (noflash)
|
||||||
libc_a-tzlock (noflash)
|
libc_a-tzlock (noflash)
|
||||||
libc_a-tzcalc_limits (noflash)
|
libc_a-tzcalc_limits (noflash)
|
||||||
libc_a-strptime (noflash)
|
libc_a-strptime (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBCHAR_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBCHAR_IN_IRAM = y:
|
||||||
libc_a-ctype_ (noflash)
|
libc_a-ctype_ (noflash)
|
||||||
libc_a-toupper (noflash)
|
libc_a-toupper (noflash)
|
||||||
libc_a-tolower (noflash)
|
libc_a-tolower (noflash)
|
||||||
libc_a-toascii (noflash)
|
libc_a-toascii (noflash)
|
||||||
libc_a-strupr (noflash)
|
libc_a-strupr (noflash)
|
||||||
libc_a-bzero (noflash)
|
libc_a-bzero (noflash)
|
||||||
libc_a-isalnum (noflash)
|
libc_a-isalnum (noflash)
|
||||||
libc_a-isalpha (noflash)
|
libc_a-isalpha (noflash)
|
||||||
libc_a-isascii (noflash)
|
libc_a-isascii (noflash)
|
||||||
libc_a-isblank (noflash)
|
libc_a-isblank (noflash)
|
||||||
libc_a-iscntrl (noflash)
|
libc_a-iscntrl (noflash)
|
||||||
libc_a-isdigit (noflash)
|
libc_a-isdigit (noflash)
|
||||||
libc_a-isgraph (noflash)
|
libc_a-isgraph (noflash)
|
||||||
libc_a-islower (noflash)
|
libc_a-islower (noflash)
|
||||||
libc_a-isprint (noflash)
|
libc_a-isprint (noflash)
|
||||||
libc_a-ispunct (noflash)
|
libc_a-ispunct (noflash)
|
||||||
libc_a-isspace (noflash)
|
libc_a-isspace (noflash)
|
||||||
libc_a-isupper (noflash)
|
libc_a-isupper (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBMEM_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBMEM_IN_IRAM = y:
|
||||||
libc_a-memccpy (noflash)
|
libc_a-memccpy (noflash)
|
||||||
libc_a-memchr (noflash)
|
libc_a-memchr (noflash)
|
||||||
libc_a-memmove (noflash)
|
libc_a-memmove (noflash)
|
||||||
libc_a-memrchr (noflash)
|
libc_a-memrchr (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBSTR_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBSTR_IN_IRAM = y:
|
||||||
libc_a-strcasecmp (noflash)
|
libc_a-strcasecmp (noflash)
|
||||||
libc_a-strcasestr (noflash)
|
libc_a-strcasestr (noflash)
|
||||||
libc_a-strchr (noflash)
|
libc_a-strchr (noflash)
|
||||||
libc_a-strcoll (noflash)
|
libc_a-strcoll (noflash)
|
||||||
libc_a-strcpy (noflash)
|
libc_a-strcpy (noflash)
|
||||||
libc_a-strcspn (noflash)
|
libc_a-strcspn (noflash)
|
||||||
libc_a-strdup (noflash)
|
libc_a-strdup (noflash)
|
||||||
libc_a-strdup_r (noflash)
|
libc_a-strdup_r (noflash)
|
||||||
libc_a-strlcat (noflash)
|
libc_a-strlcat (noflash)
|
||||||
libc_a-strlcpy (noflash)
|
libc_a-strlcpy (noflash)
|
||||||
libc_a-strlwr (noflash)
|
libc_a-strlwr (noflash)
|
||||||
libc_a-strncasecmp (noflash)
|
libc_a-strncasecmp (noflash)
|
||||||
libc_a-strncat (noflash)
|
libc_a-strncat (noflash)
|
||||||
libc_a-strncmp (noflash)
|
libc_a-strncmp (noflash)
|
||||||
libc_a-strncpy (noflash)
|
libc_a-strncpy (noflash)
|
||||||
libc_a-strndup (noflash)
|
libc_a-strndup (noflash)
|
||||||
libc_a-strndup_r (noflash)
|
libc_a-strndup_r (noflash)
|
||||||
libc_a-strnlen (noflash)
|
libc_a-strnlen (noflash)
|
||||||
libc_a-strrchr (noflash)
|
libc_a-strrchr (noflash)
|
||||||
libc_a-strsep (noflash)
|
libc_a-strsep (noflash)
|
||||||
libc_a-strspn (noflash)
|
libc_a-strspn (noflash)
|
||||||
libc_a-strstr (noflash)
|
libc_a-strstr (noflash)
|
||||||
libc_a-strtok_r (noflash)
|
libc_a-strtok_r (noflash)
|
||||||
libc_a-strupr (noflash)
|
libc_a-strupr (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBRAND_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBRAND_IN_IRAM = y:
|
||||||
libc_a-srand (noflash)
|
libc_a-srand (noflash)
|
||||||
libc_a-rand (noflash)
|
libc_a-rand (noflash)
|
||||||
libc_a-rand_r (noflash)
|
libc_a-rand_r (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBENV_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBENV_IN_IRAM = y:
|
||||||
libc_a-environ (noflash)
|
libc_a-environ (noflash)
|
||||||
libc_a-envlock (noflash)
|
libc_a-envlock (noflash)
|
||||||
libc_a-getenv_r (noflash)
|
libc_a-getenv_r (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBFILE_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBFILE_IN_IRAM = y:
|
||||||
lock (noflash)
|
lock (noflash)
|
||||||
isatty (noflash)
|
isatty (noflash)
|
||||||
creat (noflash)
|
creat (noflash)
|
||||||
libc_a-fclose (noflash)
|
libc_a-fclose (noflash)
|
||||||
libc_a-open (noflash)
|
libc_a-open (noflash)
|
||||||
libc_a-close (noflash)
|
libc_a-close (noflash)
|
||||||
libc_a-creat (noflash)
|
libc_a-creat (noflash)
|
||||||
libc_a-read (noflash)
|
libc_a-read (noflash)
|
||||||
libc_a-rshift (noflash)
|
libc_a-rshift (noflash)
|
||||||
libc_a-sbrk (noflash)
|
libc_a-sbrk (noflash)
|
||||||
libc_a-stdio (noflash)
|
libc_a-stdio (noflash)
|
||||||
libc_a-syssbrk (noflash)
|
libc_a-syssbrk (noflash)
|
||||||
libc_a-sysclose (noflash)
|
libc_a-sysclose (noflash)
|
||||||
libc_a-sysopen (noflash)
|
libc_a-sysopen (noflash)
|
||||||
libc_a-sysread (noflash)
|
libc_a-sysread (noflash)
|
||||||
libc_a-syswrite (noflash)
|
libc_a-syswrite (noflash)
|
||||||
libc_a-impure (noflash)
|
libc_a-impure (noflash)
|
||||||
libc_a-fwalk (noflash)
|
libc_a-fwalk (noflash)
|
||||||
libc_a-findfp (noflash)
|
libc_a-findfp (noflash)
|
||||||
|
|
||||||
if SPIRAM_CACHE_LIBMISC_IN_IRAM = y:
|
if SPIRAM_CACHE_LIBMISC_IN_IRAM = y:
|
||||||
libc_a-raise (noflash)
|
libc_a-raise (noflash)
|
||||||
libc_a-system (noflash)
|
libc_a-system (noflash)
|
||||||
|
|||||||
+32
-32
@@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
|
|
||||||
void flockfile(FILE *fp)
|
void flockfile(FILE *fp)
|
||||||
{
|
{
|
||||||
if (fp && !(fp->_flags & __SSTR)) {
|
if (fp && !(fp->_flags & __SSTR)) {
|
||||||
__lock_acquire_recursive(fp->_lock);
|
__lock_acquire_recursive(fp->_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ftrylockfile(FILE *fp)
|
int ftrylockfile(FILE *fp)
|
||||||
{
|
{
|
||||||
if (fp && !(fp->_flags & __SSTR)) {
|
if (fp && !(fp->_flags & __SSTR)) {
|
||||||
return __lock_try_acquire_recursive(fp->_lock);
|
return __lock_try_acquire_recursive(fp->_lock);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void funlockfile(FILE *fp)
|
void funlockfile(FILE *fp)
|
||||||
{
|
{
|
||||||
if (fp && !(fp->_flags & __SSTR)) {
|
if (fp && !(fp->_flags & __SSTR)) {
|
||||||
__lock_release_recursive(fp->_lock);
|
__lock_release_recursive(fp->_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-35
@@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
int getentropy(void *buffer, size_t length)
|
int getentropy(void *buffer, size_t length)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > 256) {
|
if (length > 256) {
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = getrandom(buffer, length, 0);
|
ret = getrandom(buffer, length, 0);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void newlib_include_getentropy_impl(void)
|
void newlib_include_getentropy_impl(void)
|
||||||
{
|
{
|
||||||
// Linker hook, exists for no other purpose
|
// Linker hook, exists for no other purpose
|
||||||
}
|
}
|
||||||
|
|||||||
+139
-139
@@ -1,139 +1,139 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These contain the business logic for the malloc() and realloc() implementation. Because of heap tracing
|
These contain the business logic for the malloc() and realloc() implementation. Because of heap tracing
|
||||||
wrapping reasons, we do not want these to be a public api, however, so they're not defined publicly.
|
wrapping reasons, we do not want these to be a public api, however, so they're not defined publicly.
|
||||||
*/
|
*/
|
||||||
extern void *heap_caps_malloc_default(size_t size);
|
extern void *heap_caps_malloc_default(size_t size);
|
||||||
extern void *heap_caps_realloc_default(void *ptr, size_t size);
|
extern void *heap_caps_realloc_default(void *ptr, size_t size);
|
||||||
extern void *heap_caps_aligned_alloc_default(size_t alignment, size_t size);
|
extern void *heap_caps_aligned_alloc_default(size_t alignment, size_t size);
|
||||||
|
|
||||||
void* malloc(size_t size)
|
void* malloc(size_t size)
|
||||||
{
|
{
|
||||||
return heap_caps_malloc_default(size);
|
return heap_caps_malloc_default(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* calloc(size_t n, size_t size)
|
void* calloc(size_t n, size_t size)
|
||||||
{
|
{
|
||||||
return _calloc_r(_REENT, n, size);
|
return _calloc_r(_REENT, n, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* realloc(void* ptr, size_t size)
|
void* realloc(void* ptr, size_t size)
|
||||||
{
|
{
|
||||||
return heap_caps_realloc_default(ptr, size);
|
return heap_caps_realloc_default(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free(void *ptr)
|
void free(void *ptr)
|
||||||
{
|
{
|
||||||
heap_caps_free(ptr);
|
heap_caps_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* _malloc_r(struct _reent *r, size_t size)
|
void* _malloc_r(struct _reent *r, size_t size)
|
||||||
{
|
{
|
||||||
return heap_caps_malloc_default(size);
|
return heap_caps_malloc_default(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _free_r(struct _reent *r, void* ptr)
|
void _free_r(struct _reent *r, void* ptr)
|
||||||
{
|
{
|
||||||
heap_caps_free(ptr);
|
heap_caps_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* _realloc_r(struct _reent *r, void* ptr, size_t size)
|
void* _realloc_r(struct _reent *r, void* ptr, size_t size)
|
||||||
{
|
{
|
||||||
return heap_caps_realloc_default(ptr, size);
|
return heap_caps_realloc_default(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* _calloc_r(struct _reent *r, size_t nmemb, size_t size)
|
void* _calloc_r(struct _reent *r, size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
void *result;
|
void *result;
|
||||||
size_t size_bytes;
|
size_t size_bytes;
|
||||||
if (__builtin_mul_overflow(nmemb, size, &size_bytes)) {
|
if (__builtin_mul_overflow(nmemb, size, &size_bytes)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = heap_caps_malloc_default(size_bytes);
|
result = heap_caps_malloc_default(size_bytes);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
bzero(result, size_bytes);
|
bzero(result, size_bytes);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* memalign(size_t alignment, size_t n)
|
void* memalign(size_t alignment, size_t n)
|
||||||
{
|
{
|
||||||
return heap_caps_aligned_alloc_default(alignment, n);
|
return heap_caps_aligned_alloc_default(alignment, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* aligned_alloc(size_t alignment, size_t n)
|
void* aligned_alloc(size_t alignment, size_t n)
|
||||||
{
|
{
|
||||||
return heap_caps_aligned_alloc_default(alignment, n);
|
return heap_caps_aligned_alloc_default(alignment, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int posix_memalign(void **out_ptr, size_t alignment, size_t size)
|
int posix_memalign(void **out_ptr, size_t alignment, size_t size)
|
||||||
{
|
{
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
/* returning NULL for zero size is allowed, don't treat this as an error */
|
/* returning NULL for zero size is allowed, don't treat this as an error */
|
||||||
*out_ptr = NULL;
|
*out_ptr = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void *result = heap_caps_aligned_alloc_default(alignment, size);
|
void *result = heap_caps_aligned_alloc_default(alignment, size);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
/* Modify output pointer only on success */
|
/* Modify output pointer only on success */
|
||||||
*out_ptr = result;
|
*out_ptr = result;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Note: error returned, not set via errno! */
|
/* Note: error returned, not set via errno! */
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No-op function, used to force linking this file,
|
/* No-op function, used to force linking this file,
|
||||||
instead of the heap implementation from newlib.
|
instead of the heap implementation from newlib.
|
||||||
*/
|
*/
|
||||||
void newlib_include_heap_impl(void)
|
void newlib_include_heap_impl(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following functions are implemented by newlib's heap allocator,
|
/* The following functions are implemented by newlib's heap allocator,
|
||||||
but aren't available in the heap component.
|
but aren't available in the heap component.
|
||||||
Define them as non-functional stubs here, so that the application
|
Define them as non-functional stubs here, so that the application
|
||||||
can not cause the newlib heap implementation to be linked in
|
can not cause the newlib heap implementation to be linked in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int malloc_trim(size_t pad)
|
int malloc_trim(size_t pad)
|
||||||
{
|
{
|
||||||
return 0; // indicates failure
|
return 0; // indicates failure
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t malloc_usable_size(void* p)
|
size_t malloc_usable_size(void* p)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void malloc_stats(void)
|
void malloc_stats(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int mallopt(int parameter_number, int parameter_value)
|
int mallopt(int parameter_number, int parameter_value)
|
||||||
{
|
{
|
||||||
return 0; // indicates failure
|
return 0; // indicates failure
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mallinfo mallinfo(void)
|
struct mallinfo mallinfo(void)
|
||||||
{
|
{
|
||||||
struct mallinfo dummy = {0};
|
struct mallinfo dummy = {0};
|
||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* valloc(size_t n) __attribute__((alias("malloc")));
|
void* valloc(size_t n) __attribute__((alias("malloc")));
|
||||||
void* pvalloc(size_t n) __attribute__((alias("malloc")));
|
void* pvalloc(size_t n) __attribute__((alias("malloc")));
|
||||||
void cfree(void* p) __attribute__((alias("free")));
|
void cfree(void* p) __attribute__((alias("free")));
|
||||||
|
|||||||
+407
-407
@@ -1,407 +1,407 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/portable.h"
|
#include "freertos/portable.h"
|
||||||
#include "esp_rom_caps.h"
|
#include "esp_rom_caps.h"
|
||||||
|
|
||||||
/* Notes on our newlib lock implementation:
|
/* Notes on our newlib lock implementation:
|
||||||
*
|
*
|
||||||
* - Use FreeRTOS mutex semaphores as locks.
|
* - Use FreeRTOS mutex semaphores as locks.
|
||||||
* - lock_t is int, but we store an SemaphoreHandle_t there.
|
* - lock_t is int, but we store an SemaphoreHandle_t there.
|
||||||
* - Locks are no-ops until the FreeRTOS scheduler is running.
|
* - Locks are no-ops until the FreeRTOS scheduler is running.
|
||||||
* - Due to this, locks need to be lazily initialised the first time
|
* - Due to this, locks need to be lazily initialised the first time
|
||||||
* they are acquired. Initialisation/deinitialisation of locks is
|
* they are acquired. Initialisation/deinitialisation of locks is
|
||||||
* protected by lock_init_spinlock.
|
* protected by lock_init_spinlock.
|
||||||
* - Race conditions around lazy initialisation (via lock_acquire) are
|
* - Race conditions around lazy initialisation (via lock_acquire) are
|
||||||
* protected against.
|
* protected against.
|
||||||
* - Anyone calling lock_close is reponsible for ensuring noone else
|
* - Anyone calling lock_close is reponsible for ensuring noone else
|
||||||
* is holding the lock at this time.
|
* is holding the lock at this time.
|
||||||
* - Race conditions between lock_close & lock_init (for the same lock)
|
* - Race conditions between lock_close & lock_init (for the same lock)
|
||||||
* are the responsibility of the caller.
|
* are the responsibility of the caller.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static portMUX_TYPE lock_init_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE lock_init_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
|
||||||
/* Initialize the given lock by allocating a new mutex semaphore
|
/* Initialize the given lock by allocating a new mutex semaphore
|
||||||
as the _lock_t value.
|
as the _lock_t value.
|
||||||
|
|
||||||
Called by _lock_init*, also called by _lock_acquire* to lazily initialize locks that might have
|
Called by _lock_init*, also called by _lock_acquire* to lazily initialize locks that might have
|
||||||
been initialised (to zero only) before the RTOS scheduler started.
|
been initialised (to zero only) before the RTOS scheduler started.
|
||||||
*/
|
*/
|
||||||
static void IRAM_ATTR lock_init_generic(_lock_t *lock, uint8_t mutex_type)
|
static void IRAM_ATTR lock_init_generic(_lock_t *lock, uint8_t mutex_type)
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&lock_init_spinlock);
|
portENTER_CRITICAL(&lock_init_spinlock);
|
||||||
if (*lock) {
|
if (*lock) {
|
||||||
/* Lock already initialised (either we didn't check earlier,
|
/* Lock already initialised (either we didn't check earlier,
|
||||||
or it got initialised while we were waiting for the
|
or it got initialised while we were waiting for the
|
||||||
spinlock.) */
|
spinlock.) */
|
||||||
} else {
|
} else {
|
||||||
/* Create a new semaphore
|
/* Create a new semaphore
|
||||||
|
|
||||||
this is a bit of an API violation, as we're calling the
|
this is a bit of an API violation, as we're calling the
|
||||||
private function xQueueCreateMutex(x) directly instead of
|
private function xQueueCreateMutex(x) directly instead of
|
||||||
the xSemaphoreCreateMutex / xSemaphoreCreateRecursiveMutex
|
the xSemaphoreCreateMutex / xSemaphoreCreateRecursiveMutex
|
||||||
wrapper functions...
|
wrapper functions...
|
||||||
|
|
||||||
The better alternative would be to pass pointers to one of
|
The better alternative would be to pass pointers to one of
|
||||||
the two xSemaphoreCreate___Mutex functions, but as FreeRTOS
|
the two xSemaphoreCreate___Mutex functions, but as FreeRTOS
|
||||||
implements these as macros instead of inline functions
|
implements these as macros instead of inline functions
|
||||||
(*party like it's 1998!*) it's not possible to do this
|
(*party like it's 1998!*) it's not possible to do this
|
||||||
without writing wrappers. Doing it this way seems much less
|
without writing wrappers. Doing it this way seems much less
|
||||||
spaghetti-like.
|
spaghetti-like.
|
||||||
*/
|
*/
|
||||||
SemaphoreHandle_t new_sem = xQueueCreateMutex(mutex_type);
|
SemaphoreHandle_t new_sem = xQueueCreateMutex(mutex_type);
|
||||||
if (!new_sem) {
|
if (!new_sem) {
|
||||||
abort(); /* No more semaphores available or OOM */
|
abort(); /* No more semaphores available or OOM */
|
||||||
}
|
}
|
||||||
*lock = (_lock_t)new_sem;
|
*lock = (_lock_t)new_sem;
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL(&lock_init_spinlock);
|
portEXIT_CRITICAL(&lock_init_spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR _lock_init(_lock_t *lock)
|
void IRAM_ATTR _lock_init(_lock_t *lock)
|
||||||
{
|
{
|
||||||
*lock = 0; // In case lock's memory is uninitialized
|
*lock = 0; // In case lock's memory is uninitialized
|
||||||
lock_init_generic(lock, queueQUEUE_TYPE_MUTEX);
|
lock_init_generic(lock, queueQUEUE_TYPE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR _lock_init_recursive(_lock_t *lock)
|
void IRAM_ATTR _lock_init_recursive(_lock_t *lock)
|
||||||
{
|
{
|
||||||
*lock = 0; // In case lock's memory is uninitialized
|
*lock = 0; // In case lock's memory is uninitialized
|
||||||
lock_init_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
lock_init_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the mutex semaphore pointed to by *lock, and zero it out.
|
/* Free the mutex semaphore pointed to by *lock, and zero it out.
|
||||||
|
|
||||||
Note that FreeRTOS doesn't account for deleting mutexes while they
|
Note that FreeRTOS doesn't account for deleting mutexes while they
|
||||||
are held, and neither do we... so take care not to delete newlib
|
are held, and neither do we... so take care not to delete newlib
|
||||||
locks while they may be held by other tasks!
|
locks while they may be held by other tasks!
|
||||||
|
|
||||||
Also, deleting a lock in this way will cause it to be lazily
|
Also, deleting a lock in this way will cause it to be lazily
|
||||||
re-initialised if it is used again. Caller has to avoid doing
|
re-initialised if it is used again. Caller has to avoid doing
|
||||||
this!
|
this!
|
||||||
*/
|
*/
|
||||||
void IRAM_ATTR _lock_close(_lock_t *lock)
|
void IRAM_ATTR _lock_close(_lock_t *lock)
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&lock_init_spinlock);
|
portENTER_CRITICAL(&lock_init_spinlock);
|
||||||
if (*lock) {
|
if (*lock) {
|
||||||
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
|
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
|
||||||
#if (INCLUDE_xSemaphoreGetMutexHolder == 1)
|
#if (INCLUDE_xSemaphoreGetMutexHolder == 1)
|
||||||
configASSERT(xSemaphoreGetMutexHolder(h) == NULL); /* mutex should not be held */
|
configASSERT(xSemaphoreGetMutexHolder(h) == NULL); /* mutex should not be held */
|
||||||
#endif
|
#endif
|
||||||
vSemaphoreDelete(h);
|
vSemaphoreDelete(h);
|
||||||
*lock = 0;
|
*lock = 0;
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL(&lock_init_spinlock);
|
portEXIT_CRITICAL(&lock_init_spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _lock_close_recursive(_lock_t *lock) __attribute__((alias("_lock_close")));
|
void _lock_close_recursive(_lock_t *lock) __attribute__((alias("_lock_close")));
|
||||||
|
|
||||||
/* Acquire the mutex semaphore for lock. wait up to delay ticks.
|
/* Acquire the mutex semaphore for lock. wait up to delay ticks.
|
||||||
mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX
|
mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX
|
||||||
*/
|
*/
|
||||||
static int IRAM_ATTR lock_acquire_generic(_lock_t *lock, uint32_t delay, uint8_t mutex_type)
|
static int IRAM_ATTR lock_acquire_generic(_lock_t *lock, uint32_t delay, uint8_t mutex_type)
|
||||||
{
|
{
|
||||||
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
|
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
|
||||||
if (!h) {
|
if (!h) {
|
||||||
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
|
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
|
||||||
return 0; /* locking is a no-op before scheduler is up, so this "succeeds" */
|
return 0; /* locking is a no-op before scheduler is up, so this "succeeds" */
|
||||||
}
|
}
|
||||||
/* lazy initialise lock - might have had a static initializer (that we don't use) */
|
/* lazy initialise lock - might have had a static initializer (that we don't use) */
|
||||||
lock_init_generic(lock, mutex_type);
|
lock_init_generic(lock, mutex_type);
|
||||||
h = (SemaphoreHandle_t)(*lock);
|
h = (SemaphoreHandle_t)(*lock);
|
||||||
configASSERT(h != NULL);
|
configASSERT(h != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
|
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
|
||||||
return 0; /* locking is a no-op before scheduler is up, so this "succeeds" */
|
return 0; /* locking is a no-op before scheduler is up, so this "succeeds" */
|
||||||
}
|
}
|
||||||
BaseType_t success;
|
BaseType_t success;
|
||||||
if (!xPortCanYield()) {
|
if (!xPortCanYield()) {
|
||||||
/* In ISR Context */
|
/* In ISR Context */
|
||||||
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
||||||
abort(); /* recursive mutexes make no sense in ISR context */
|
abort(); /* recursive mutexes make no sense in ISR context */
|
||||||
}
|
}
|
||||||
BaseType_t higher_task_woken = false;
|
BaseType_t higher_task_woken = false;
|
||||||
success = xSemaphoreTakeFromISR(h, &higher_task_woken);
|
success = xSemaphoreTakeFromISR(h, &higher_task_woken);
|
||||||
if (!success && delay > 0) {
|
if (!success && delay > 0) {
|
||||||
abort(); /* Tried to block on mutex from ISR, couldn't... rewrite your program to avoid libc interactions in ISRs! */
|
abort(); /* Tried to block on mutex from ISR, couldn't... rewrite your program to avoid libc interactions in ISRs! */
|
||||||
}
|
}
|
||||||
if (higher_task_woken) {
|
if (higher_task_woken) {
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* In task context */
|
/* In task context */
|
||||||
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
||||||
success = xSemaphoreTakeRecursive(h, delay);
|
success = xSemaphoreTakeRecursive(h, delay);
|
||||||
} else {
|
} else {
|
||||||
success = xSemaphoreTake(h, delay);
|
success = xSemaphoreTake(h, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (success == pdTRUE) ? 0 : -1;
|
return (success == pdTRUE) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR _lock_acquire(_lock_t *lock)
|
void IRAM_ATTR _lock_acquire(_lock_t *lock)
|
||||||
{
|
{
|
||||||
lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_MUTEX);
|
lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR _lock_acquire_recursive(_lock_t *lock)
|
void IRAM_ATTR _lock_acquire_recursive(_lock_t *lock)
|
||||||
{
|
{
|
||||||
lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRAM_ATTR _lock_try_acquire(_lock_t *lock)
|
int IRAM_ATTR _lock_try_acquire(_lock_t *lock)
|
||||||
{
|
{
|
||||||
return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_MUTEX);
|
return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRAM_ATTR _lock_try_acquire_recursive(_lock_t *lock)
|
int IRAM_ATTR _lock_try_acquire_recursive(_lock_t *lock)
|
||||||
{
|
{
|
||||||
return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the mutex semaphore for lock.
|
/* Release the mutex semaphore for lock.
|
||||||
mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX
|
mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX
|
||||||
*/
|
*/
|
||||||
static void IRAM_ATTR lock_release_generic(_lock_t *lock, uint8_t mutex_type)
|
static void IRAM_ATTR lock_release_generic(_lock_t *lock, uint8_t mutex_type)
|
||||||
{
|
{
|
||||||
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
|
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
|
||||||
return; /* locking is a no-op before scheduler is up */
|
return; /* locking is a no-op before scheduler is up */
|
||||||
}
|
}
|
||||||
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
|
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
|
||||||
assert(h);
|
assert(h);
|
||||||
|
|
||||||
if (!xPortCanYield()) {
|
if (!xPortCanYield()) {
|
||||||
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
||||||
abort(); /* indicates logic bug, it shouldn't be possible to lock recursively in ISR */
|
abort(); /* indicates logic bug, it shouldn't be possible to lock recursively in ISR */
|
||||||
}
|
}
|
||||||
BaseType_t higher_task_woken = false;
|
BaseType_t higher_task_woken = false;
|
||||||
xSemaphoreGiveFromISR(h, &higher_task_woken);
|
xSemaphoreGiveFromISR(h, &higher_task_woken);
|
||||||
if (higher_task_woken) {
|
if (higher_task_woken) {
|
||||||
portYIELD_FROM_ISR();
|
portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
||||||
xSemaphoreGiveRecursive(h);
|
xSemaphoreGiveRecursive(h);
|
||||||
} else {
|
} else {
|
||||||
xSemaphoreGive(h);
|
xSemaphoreGive(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR _lock_release(_lock_t *lock)
|
void IRAM_ATTR _lock_release(_lock_t *lock)
|
||||||
{
|
{
|
||||||
lock_release_generic(lock, queueQUEUE_TYPE_MUTEX);
|
lock_release_generic(lock, queueQUEUE_TYPE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR _lock_release_recursive(_lock_t *lock)
|
void IRAM_ATTR _lock_release_recursive(_lock_t *lock)
|
||||||
{
|
{
|
||||||
lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* To ease the transition to newlib 3.3.0, this part is kept under an ifdef.
|
/* To ease the transition to newlib 3.3.0, this part is kept under an ifdef.
|
||||||
* After the toolchain with newlib 3.3.0 is released and merged, the ifdefs
|
* After the toolchain with newlib 3.3.0 is released and merged, the ifdefs
|
||||||
* can be removed.
|
* can be removed.
|
||||||
*
|
*
|
||||||
* Also the retargetable locking functions still rely on the previous
|
* Also the retargetable locking functions still rely on the previous
|
||||||
* implementation. Once support for !_RETARGETABLE_LOCKING is removed,
|
* implementation. Once support for !_RETARGETABLE_LOCKING is removed,
|
||||||
* the code can be simplified, removing support for lazy initialization of
|
* the code can be simplified, removing support for lazy initialization of
|
||||||
* locks. At the same time, IDF code which relies on _lock_acquire/_lock_release
|
* locks. At the same time, IDF code which relies on _lock_acquire/_lock_release
|
||||||
* will have to be updated to not depend on lazy initialization.
|
* will have to be updated to not depend on lazy initialization.
|
||||||
*
|
*
|
||||||
* Explanation of the different lock types:
|
* Explanation of the different lock types:
|
||||||
*
|
*
|
||||||
* Newlib 2.2.0 and 3.0.0:
|
* Newlib 2.2.0 and 3.0.0:
|
||||||
* _lock_t is defined as int, stores SemaphoreHandle_t.
|
* _lock_t is defined as int, stores SemaphoreHandle_t.
|
||||||
*
|
*
|
||||||
* Newlib 3.3.0:
|
* Newlib 3.3.0:
|
||||||
* struct __lock is (or contains) StaticSemaphore_t
|
* struct __lock is (or contains) StaticSemaphore_t
|
||||||
* _LOCK_T is a pointer to struct __lock, equivalent to SemaphoreHandle_t.
|
* _LOCK_T is a pointer to struct __lock, equivalent to SemaphoreHandle_t.
|
||||||
* It has the same meaning as _lock_t in the previous implementation.
|
* It has the same meaning as _lock_t in the previous implementation.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This ensures the platform-specific definition in lock.h is correct.
|
/* This ensures the platform-specific definition in lock.h is correct.
|
||||||
* We use "greater or equal" since the size of StaticSemaphore_t may
|
* We use "greater or equal" since the size of StaticSemaphore_t may
|
||||||
* vary by 2 words, depending on whether configUSE_TRACE_FACILITY is enabled.
|
* vary by 2 words, depending on whether configUSE_TRACE_FACILITY is enabled.
|
||||||
*/
|
*/
|
||||||
_Static_assert(sizeof(struct __lock) >= sizeof(StaticSemaphore_t),
|
_Static_assert(sizeof(struct __lock) >= sizeof(StaticSemaphore_t),
|
||||||
"Incorrect size of struct __lock");
|
"Incorrect size of struct __lock");
|
||||||
|
|
||||||
/* FreeRTOS configuration check */
|
/* FreeRTOS configuration check */
|
||||||
_Static_assert(configSUPPORT_STATIC_ALLOCATION,
|
_Static_assert(configSUPPORT_STATIC_ALLOCATION,
|
||||||
"FreeRTOS should be configured with static allocation support");
|
"FreeRTOS should be configured with static allocation support");
|
||||||
|
|
||||||
/* These 2 locks are used instead of 9 distinct newlib static locks,
|
/* These 2 locks are used instead of 9 distinct newlib static locks,
|
||||||
* as most of the locks are required for lesser-used features, so
|
* as most of the locks are required for lesser-used features, so
|
||||||
* the chance of performance degradation due to lock contention is low.
|
* the chance of performance degradation due to lock contention is low.
|
||||||
*/
|
*/
|
||||||
static StaticSemaphore_t s_common_mutex;
|
static StaticSemaphore_t s_common_mutex;
|
||||||
static StaticSemaphore_t s_common_recursive_mutex;
|
static StaticSemaphore_t s_common_recursive_mutex;
|
||||||
|
|
||||||
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||||
/* C3 and S3 ROMs are built without Newlib static lock symbols exported, and
|
/* C3 and S3 ROMs are built without Newlib static lock symbols exported, and
|
||||||
* with an extra level of _LOCK_T indirection in mind.
|
* with an extra level of _LOCK_T indirection in mind.
|
||||||
* The following is a workaround for this:
|
* The following is a workaround for this:
|
||||||
* - on startup, we call esp_rom_newlib_init_common_mutexes to set
|
* - on startup, we call esp_rom_newlib_init_common_mutexes to set
|
||||||
* the two mutex pointers to magic values.
|
* the two mutex pointers to magic values.
|
||||||
* - if in __retarget_lock_acquire*, we check if the argument dereferences
|
* - if in __retarget_lock_acquire*, we check if the argument dereferences
|
||||||
* to the magic value. If yes, we lock the correct mutex defined in the app,
|
* to the magic value. If yes, we lock the correct mutex defined in the app,
|
||||||
* instead.
|
* instead.
|
||||||
* Casts from &StaticSemaphore_t to _LOCK_T are okay because _LOCK_T
|
* Casts from &StaticSemaphore_t to _LOCK_T are okay because _LOCK_T
|
||||||
* (which is SemaphoreHandle_t) is a pointer to the corresponding
|
* (which is SemaphoreHandle_t) is a pointer to the corresponding
|
||||||
* StaticSemaphore_t structure. This is ensured by asserts below.
|
* StaticSemaphore_t structure. This is ensured by asserts below.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ROM_NEEDS_MUTEX_OVERRIDE
|
#define ROM_NEEDS_MUTEX_OVERRIDE
|
||||||
#endif // ESP_ROM_HAS_RETARGETABLE_LOCKING
|
#endif // ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||||
|
|
||||||
#ifdef ROM_NEEDS_MUTEX_OVERRIDE
|
#ifdef ROM_NEEDS_MUTEX_OVERRIDE
|
||||||
#define ROM_MUTEX_MAGIC 0xbb10c433
|
#define ROM_MUTEX_MAGIC 0xbb10c433
|
||||||
/* This is a macro, since we are overwriting the argument */
|
/* This is a macro, since we are overwriting the argument */
|
||||||
#define MAYBE_OVERRIDE_LOCK(_lock, _lock_to_use_instead) \
|
#define MAYBE_OVERRIDE_LOCK(_lock, _lock_to_use_instead) \
|
||||||
if (*(int*)_lock == ROM_MUTEX_MAGIC) { \
|
if (*(int*)_lock == ROM_MUTEX_MAGIC) { \
|
||||||
(_lock) = (_LOCK_T) (_lock_to_use_instead); \
|
(_lock) = (_LOCK_T) (_lock_to_use_instead); \
|
||||||
}
|
}
|
||||||
#else // ROM_NEEDS_MUTEX_OVERRIDE
|
#else // ROM_NEEDS_MUTEX_OVERRIDE
|
||||||
#define MAYBE_OVERRIDE_LOCK(_lock, _lock_to_use_instead)
|
#define MAYBE_OVERRIDE_LOCK(_lock, _lock_to_use_instead)
|
||||||
#endif // ROM_NEEDS_MUTEX_OVERRIDE
|
#endif // ROM_NEEDS_MUTEX_OVERRIDE
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_init(_LOCK_T *lock)
|
void IRAM_ATTR __retarget_lock_init(_LOCK_T *lock)
|
||||||
{
|
{
|
||||||
*lock = NULL; /* In case lock's memory is uninitialized */
|
*lock = NULL; /* In case lock's memory is uninitialized */
|
||||||
lock_init_generic(lock, queueQUEUE_TYPE_MUTEX);
|
lock_init_generic(lock, queueQUEUE_TYPE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_init_recursive(_LOCK_T *lock)
|
void IRAM_ATTR __retarget_lock_init_recursive(_LOCK_T *lock)
|
||||||
{
|
{
|
||||||
*lock = NULL; /* In case lock's memory is uninitialized */
|
*lock = NULL; /* In case lock's memory is uninitialized */
|
||||||
lock_init_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
lock_init_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_close(_LOCK_T lock)
|
void IRAM_ATTR __retarget_lock_close(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
_lock_close(&lock);
|
_lock_close(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_close_recursive(_LOCK_T lock)
|
void IRAM_ATTR __retarget_lock_close_recursive(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
_lock_close_recursive(&lock);
|
_lock_close_recursive(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Separate function, to prevent generating multiple assert strings */
|
/* Separate function, to prevent generating multiple assert strings */
|
||||||
static void IRAM_ATTR check_lock_nonzero(_LOCK_T lock)
|
static void IRAM_ATTR check_lock_nonzero(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
assert(lock != NULL && "Uninitialized lock used");
|
assert(lock != NULL && "Uninitialized lock used");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_acquire(_LOCK_T lock)
|
void IRAM_ATTR __retarget_lock_acquire(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
check_lock_nonzero(lock);
|
check_lock_nonzero(lock);
|
||||||
MAYBE_OVERRIDE_LOCK(lock, &s_common_mutex);
|
MAYBE_OVERRIDE_LOCK(lock, &s_common_mutex);
|
||||||
_lock_acquire(&lock);
|
_lock_acquire(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_acquire_recursive(_LOCK_T lock)
|
void IRAM_ATTR __retarget_lock_acquire_recursive(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
check_lock_nonzero(lock);
|
check_lock_nonzero(lock);
|
||||||
MAYBE_OVERRIDE_LOCK(lock, &s_common_recursive_mutex);
|
MAYBE_OVERRIDE_LOCK(lock, &s_common_recursive_mutex);
|
||||||
_lock_acquire_recursive(&lock);
|
_lock_acquire_recursive(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRAM_ATTR __retarget_lock_try_acquire(_LOCK_T lock)
|
int IRAM_ATTR __retarget_lock_try_acquire(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
check_lock_nonzero(lock);
|
check_lock_nonzero(lock);
|
||||||
MAYBE_OVERRIDE_LOCK(lock, &s_common_mutex);
|
MAYBE_OVERRIDE_LOCK(lock, &s_common_mutex);
|
||||||
return _lock_try_acquire(&lock);
|
return _lock_try_acquire(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRAM_ATTR __retarget_lock_try_acquire_recursive(_LOCK_T lock)
|
int IRAM_ATTR __retarget_lock_try_acquire_recursive(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
check_lock_nonzero(lock);
|
check_lock_nonzero(lock);
|
||||||
MAYBE_OVERRIDE_LOCK(lock, &s_common_recursive_mutex);
|
MAYBE_OVERRIDE_LOCK(lock, &s_common_recursive_mutex);
|
||||||
return _lock_try_acquire_recursive(&lock);
|
return _lock_try_acquire_recursive(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_release(_LOCK_T lock)
|
void IRAM_ATTR __retarget_lock_release(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
check_lock_nonzero(lock);
|
check_lock_nonzero(lock);
|
||||||
_lock_release(&lock);
|
_lock_release(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR __retarget_lock_release_recursive(_LOCK_T lock)
|
void IRAM_ATTR __retarget_lock_release_recursive(_LOCK_T lock)
|
||||||
{
|
{
|
||||||
check_lock_nonzero(lock);
|
check_lock_nonzero(lock);
|
||||||
_lock_release_recursive(&lock);
|
_lock_release_recursive(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When _RETARGETABLE_LOCKING is enabled, newlib expects the following locks to be provided: */
|
/* When _RETARGETABLE_LOCKING is enabled, newlib expects the following locks to be provided: */
|
||||||
|
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___sinit_recursive_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___sinit_recursive_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___malloc_recursive_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___malloc_recursive_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___env_recursive_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___env_recursive_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___sfp_recursive_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___sfp_recursive_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___atexit_recursive_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_recursive_mutex"))) __lock___atexit_recursive_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___at_quick_exit_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___at_quick_exit_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___tz_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___tz_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___dd_hash_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___dd_hash_mutex;
|
||||||
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___arc4random_mutex;
|
extern StaticSemaphore_t __attribute__((alias("s_common_mutex"))) __lock___arc4random_mutex;
|
||||||
|
|
||||||
void esp_newlib_locks_init(void)
|
void esp_newlib_locks_init(void)
|
||||||
{
|
{
|
||||||
/* Initialize the two mutexes used for the locks above.
|
/* Initialize the two mutexes used for the locks above.
|
||||||
* Asserts below check our assumption that SemaphoreHandle_t will always
|
* Asserts below check our assumption that SemaphoreHandle_t will always
|
||||||
* point to the corresponding StaticSemaphore_t structure.
|
* point to the corresponding StaticSemaphore_t structure.
|
||||||
*/
|
*/
|
||||||
SemaphoreHandle_t handle;
|
SemaphoreHandle_t handle;
|
||||||
handle = xSemaphoreCreateMutexStatic(&s_common_mutex);
|
handle = xSemaphoreCreateMutexStatic(&s_common_mutex);
|
||||||
assert(handle == (SemaphoreHandle_t) &s_common_mutex);
|
assert(handle == (SemaphoreHandle_t) &s_common_mutex);
|
||||||
handle = xSemaphoreCreateRecursiveMutexStatic(&s_common_recursive_mutex);
|
handle = xSemaphoreCreateRecursiveMutexStatic(&s_common_recursive_mutex);
|
||||||
assert(handle == (SemaphoreHandle_t) &s_common_recursive_mutex);
|
assert(handle == (SemaphoreHandle_t) &s_common_recursive_mutex);
|
||||||
(void) handle;
|
(void) handle;
|
||||||
|
|
||||||
/* Chip ROMs are built with older versions of newlib, and rely on different lock variables.
|
/* Chip ROMs are built with older versions of newlib, and rely on different lock variables.
|
||||||
* Initialize these locks to the same values.
|
* Initialize these locks to the same values.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||||
/* Newlib 2.2.0 is used in ROM, the following lock symbols are defined: */
|
/* Newlib 2.2.0 is used in ROM, the following lock symbols are defined: */
|
||||||
extern _lock_t __sfp_lock;
|
extern _lock_t __sfp_lock;
|
||||||
__sfp_lock = (_lock_t) &s_common_recursive_mutex;
|
__sfp_lock = (_lock_t) &s_common_recursive_mutex;
|
||||||
extern _lock_t __sinit_lock;
|
extern _lock_t __sinit_lock;
|
||||||
__sinit_lock = (_lock_t) &s_common_recursive_mutex;
|
__sinit_lock = (_lock_t) &s_common_recursive_mutex;
|
||||||
extern _lock_t __env_lock_object;
|
extern _lock_t __env_lock_object;
|
||||||
__env_lock_object = (_lock_t) &s_common_recursive_mutex;
|
__env_lock_object = (_lock_t) &s_common_recursive_mutex;
|
||||||
extern _lock_t __tz_lock_object;
|
extern _lock_t __tz_lock_object;
|
||||||
__tz_lock_object = (_lock_t) &s_common_mutex;
|
__tz_lock_object = (_lock_t) &s_common_mutex;
|
||||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||||
/* Newlib 3.0.0 is used in ROM, the following lock symbols are defined: */
|
/* Newlib 3.0.0 is used in ROM, the following lock symbols are defined: */
|
||||||
extern _lock_t __sinit_recursive_mutex;
|
extern _lock_t __sinit_recursive_mutex;
|
||||||
__sinit_recursive_mutex = (_lock_t) &s_common_recursive_mutex;
|
__sinit_recursive_mutex = (_lock_t) &s_common_recursive_mutex;
|
||||||
extern _lock_t __sfp_recursive_mutex;
|
extern _lock_t __sfp_recursive_mutex;
|
||||||
__sfp_recursive_mutex = (_lock_t) &s_common_recursive_mutex;
|
__sfp_recursive_mutex = (_lock_t) &s_common_recursive_mutex;
|
||||||
#elif ESP_ROM_HAS_RETARGETABLE_LOCKING
|
#elif ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||||
/* Newlib 3.3.0 is used in ROM, built with _RETARGETABLE_LOCKING.
|
/* Newlib 3.3.0 is used in ROM, built with _RETARGETABLE_LOCKING.
|
||||||
* No access to lock variables for the purpose of ECO forward compatibility,
|
* No access to lock variables for the purpose of ECO forward compatibility,
|
||||||
* however we have an API to initialize lock variables used in the ROM.
|
* however we have an API to initialize lock variables used in the ROM.
|
||||||
*/
|
*/
|
||||||
extern void esp_rom_newlib_init_common_mutexes(_LOCK_T, _LOCK_T);
|
extern void esp_rom_newlib_init_common_mutexes(_LOCK_T, _LOCK_T);
|
||||||
/* See notes about ROM_NEEDS_MUTEX_OVERRIDE above */
|
/* See notes about ROM_NEEDS_MUTEX_OVERRIDE above */
|
||||||
int magic_val = ROM_MUTEX_MAGIC;
|
int magic_val = ROM_MUTEX_MAGIC;
|
||||||
_LOCK_T magic_mutex = (_LOCK_T) &magic_val;
|
_LOCK_T magic_mutex = (_LOCK_T) &magic_val;
|
||||||
esp_rom_newlib_init_common_mutexes(magic_mutex, magic_mutex);
|
esp_rom_newlib_init_common_mutexes(magic_mutex, magic_mutex);
|
||||||
#else // other target
|
#else // other target
|
||||||
#error Unsupported target
|
#error Unsupported target
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[mapping:newlib]
|
[mapping:newlib]
|
||||||
archive: libnewlib.a
|
archive: libnewlib.a
|
||||||
entries:
|
entries:
|
||||||
heap (noflash)
|
heap (noflash)
|
||||||
abort (noflash)
|
abort (noflash)
|
||||||
assert (noflash)
|
assert (noflash)
|
||||||
stdatomic (noflash)
|
stdatomic (noflash)
|
||||||
if STDATOMIC_S32C1I_SPIRAM_WORKAROUND = y:
|
if STDATOMIC_S32C1I_SPIRAM_WORKAROUND = y:
|
||||||
stdatomic_s32c1i (noflash)
|
stdatomic_s32c1i (noflash)
|
||||||
|
|||||||
+214
-214
@@ -1,214 +1,214 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "esp_newlib.h"
|
#include "esp_newlib.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
#include "esp_rom_caps.h"
|
#include "esp_rom_caps.h"
|
||||||
#include "esp_rom_libc_stubs.h"
|
#include "esp_rom_libc_stubs.h"
|
||||||
#include "esp_private/startup_internal.h"
|
#include "esp_private/startup_internal.h"
|
||||||
|
|
||||||
extern int _printf_float(struct _reent *rptr,
|
extern int _printf_float(struct _reent *rptr,
|
||||||
void *pdata,
|
void *pdata,
|
||||||
FILE * fp,
|
FILE * fp,
|
||||||
int (*pfunc)(struct _reent *, FILE *, const char *, size_t len),
|
int (*pfunc)(struct _reent *, FILE *, const char *, size_t len),
|
||||||
va_list * ap);
|
va_list * ap);
|
||||||
|
|
||||||
extern int _scanf_float(struct _reent *rptr,
|
extern int _scanf_float(struct _reent *rptr,
|
||||||
void *pdata,
|
void *pdata,
|
||||||
FILE *fp,
|
FILE *fp,
|
||||||
va_list *ap);
|
va_list *ap);
|
||||||
|
|
||||||
static void raise_r_stub(struct _reent *rptr)
|
static void raise_r_stub(struct _reent *rptr)
|
||||||
{
|
{
|
||||||
_raise_r(rptr, 0);
|
_raise_r(rptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void esp_cleanup_r(struct _reent *rptr)
|
static void esp_cleanup_r(struct _reent *rptr)
|
||||||
{
|
{
|
||||||
if (_REENT_STDIN(rptr) != _REENT_STDIN(_GLOBAL_REENT)) {
|
if (_REENT_STDIN(rptr) != _REENT_STDIN(_GLOBAL_REENT)) {
|
||||||
_fclose_r(rptr, _REENT_STDIN(rptr));
|
_fclose_r(rptr, _REENT_STDIN(rptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_REENT_STDOUT(rptr) != _REENT_STDOUT(_GLOBAL_REENT)) {
|
if (_REENT_STDOUT(rptr) != _REENT_STDOUT(_GLOBAL_REENT)) {
|
||||||
_fclose_r(rptr, _REENT_STDOUT(rptr));
|
_fclose_r(rptr, _REENT_STDOUT(rptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_REENT_STDERR(rptr) != _REENT_STDERR(_GLOBAL_REENT)) {
|
if (_REENT_STDERR(rptr) != _REENT_STDERR(_GLOBAL_REENT)) {
|
||||||
_fclose_r(rptr, _REENT_STDERR(rptr));
|
_fclose_r(rptr, _REENT_STDERR(rptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct syscall_stub_table s_stub_table = {
|
static struct syscall_stub_table s_stub_table = {
|
||||||
.__getreent = &__getreent,
|
.__getreent = &__getreent,
|
||||||
._malloc_r = &_malloc_r,
|
._malloc_r = &_malloc_r,
|
||||||
._free_r = &_free_r,
|
._free_r = &_free_r,
|
||||||
._realloc_r = &_realloc_r,
|
._realloc_r = &_realloc_r,
|
||||||
._calloc_r = &_calloc_r,
|
._calloc_r = &_calloc_r,
|
||||||
._abort = &abort,
|
._abort = &abort,
|
||||||
._system_r = &_system_r,
|
._system_r = &_system_r,
|
||||||
._rename_r = &_rename_r,
|
._rename_r = &_rename_r,
|
||||||
._times_r = &_times_r,
|
._times_r = &_times_r,
|
||||||
._gettimeofday_r = &_gettimeofday_r,
|
._gettimeofday_r = &_gettimeofday_r,
|
||||||
._raise_r = &raise_r_stub,
|
._raise_r = &raise_r_stub,
|
||||||
._unlink_r = &_unlink_r,
|
._unlink_r = &_unlink_r,
|
||||||
._link_r = &_link_r,
|
._link_r = &_link_r,
|
||||||
._stat_r = &_stat_r,
|
._stat_r = &_stat_r,
|
||||||
._fstat_r = &_fstat_r,
|
._fstat_r = &_fstat_r,
|
||||||
._sbrk_r = &_sbrk_r,
|
._sbrk_r = &_sbrk_r,
|
||||||
._getpid_r = &_getpid_r,
|
._getpid_r = &_getpid_r,
|
||||||
._kill_r = &_kill_r,
|
._kill_r = &_kill_r,
|
||||||
._exit_r = NULL, // never called in ROM
|
._exit_r = NULL, // never called in ROM
|
||||||
._close_r = &_close_r,
|
._close_r = &_close_r,
|
||||||
._open_r = &_open_r,
|
._open_r = &_open_r,
|
||||||
._write_r = (int (*)(struct _reent * r, int, const void *, int)) &_write_r,
|
._write_r = (int (*)(struct _reent * r, int, const void *, int)) &_write_r,
|
||||||
._lseek_r = (int (*)(struct _reent * r, int, int, int)) &_lseek_r,
|
._lseek_r = (int (*)(struct _reent * r, int, int, int)) &_lseek_r,
|
||||||
._read_r = (int (*)(struct _reent * r, int, void *, int)) &_read_r,
|
._read_r = (int (*)(struct _reent * r, int, void *, int)) &_read_r,
|
||||||
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||||
._retarget_lock_init = &__retarget_lock_init,
|
._retarget_lock_init = &__retarget_lock_init,
|
||||||
._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
|
._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
|
||||||
._retarget_lock_close = &__retarget_lock_close,
|
._retarget_lock_close = &__retarget_lock_close,
|
||||||
._retarget_lock_close_recursive = &__retarget_lock_close_recursive,
|
._retarget_lock_close_recursive = &__retarget_lock_close_recursive,
|
||||||
._retarget_lock_acquire = &__retarget_lock_acquire,
|
._retarget_lock_acquire = &__retarget_lock_acquire,
|
||||||
._retarget_lock_acquire_recursive = &__retarget_lock_acquire_recursive,
|
._retarget_lock_acquire_recursive = &__retarget_lock_acquire_recursive,
|
||||||
._retarget_lock_try_acquire = &__retarget_lock_try_acquire,
|
._retarget_lock_try_acquire = &__retarget_lock_try_acquire,
|
||||||
._retarget_lock_try_acquire_recursive = &__retarget_lock_try_acquire_recursive,
|
._retarget_lock_try_acquire_recursive = &__retarget_lock_try_acquire_recursive,
|
||||||
._retarget_lock_release = &__retarget_lock_release,
|
._retarget_lock_release = &__retarget_lock_release,
|
||||||
._retarget_lock_release_recursive = &__retarget_lock_release_recursive,
|
._retarget_lock_release_recursive = &__retarget_lock_release_recursive,
|
||||||
#else
|
#else
|
||||||
._lock_init = &_lock_init,
|
._lock_init = &_lock_init,
|
||||||
._lock_init_recursive = &_lock_init_recursive,
|
._lock_init_recursive = &_lock_init_recursive,
|
||||||
._lock_close = &_lock_close,
|
._lock_close = &_lock_close,
|
||||||
._lock_close_recursive = &_lock_close_recursive,
|
._lock_close_recursive = &_lock_close_recursive,
|
||||||
._lock_acquire = &_lock_acquire,
|
._lock_acquire = &_lock_acquire,
|
||||||
._lock_acquire_recursive = &_lock_acquire_recursive,
|
._lock_acquire_recursive = &_lock_acquire_recursive,
|
||||||
._lock_try_acquire = &_lock_try_acquire,
|
._lock_try_acquire = &_lock_try_acquire,
|
||||||
._lock_try_acquire_recursive = &_lock_try_acquire_recursive,
|
._lock_try_acquire_recursive = &_lock_try_acquire_recursive,
|
||||||
._lock_release = &_lock_release,
|
._lock_release = &_lock_release,
|
||||||
._lock_release_recursive = &_lock_release_recursive,
|
._lock_release_recursive = &_lock_release_recursive,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NEWLIB_NANO_FORMAT
|
#ifdef CONFIG_NEWLIB_NANO_FORMAT
|
||||||
._printf_float = &_printf_float,
|
._printf_float = &_printf_float,
|
||||||
._scanf_float = &_scanf_float,
|
._scanf_float = &_scanf_float,
|
||||||
#else
|
#else
|
||||||
._printf_float = NULL,
|
._printf_float = NULL,
|
||||||
._scanf_float = NULL,
|
._scanf_float = NULL,
|
||||||
#endif
|
#endif
|
||||||
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S2
|
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S2
|
||||||
/* TODO IDF-2570 : mark that this assert failed in ROM, to avoid confusion between IDF & ROM
|
/* TODO IDF-2570 : mark that this assert failed in ROM, to avoid confusion between IDF & ROM
|
||||||
assertion failures (as function names & source file names will be similar)
|
assertion failures (as function names & source file names will be similar)
|
||||||
*/
|
*/
|
||||||
.__assert_func = __assert_func,
|
.__assert_func = __assert_func,
|
||||||
|
|
||||||
/* We don't expect either ROM code to ever call __sinit, so it's implemented as abort() for now.
|
/* We don't expect either ROM code to ever call __sinit, so it's implemented as abort() for now.
|
||||||
|
|
||||||
__sinit may be called in IDF side only if /dev/console used as input/output. It called only
|
__sinit may be called in IDF side only if /dev/console used as input/output. It called only
|
||||||
once for _GLOBAL_REENT. Then reuse std file pointers from _GLOBAL_REENT in another reents.
|
once for _GLOBAL_REENT. Then reuse std file pointers from _GLOBAL_REENT in another reents.
|
||||||
See esp_newlib_init() and esp_reent_init() for details.
|
See esp_newlib_init() and esp_reent_init() for details.
|
||||||
*/
|
*/
|
||||||
.__sinit = (void *)abort,
|
.__sinit = (void *)abort,
|
||||||
._cleanup_r = &esp_cleanup_r,
|
._cleanup_r = &esp_cleanup_r,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void esp_newlib_init(void)
|
void esp_newlib_init(void)
|
||||||
{
|
{
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
syscall_table_ptr_pro = syscall_table_ptr_app = &s_stub_table;
|
syscall_table_ptr_pro = syscall_table_ptr_app = &s_stub_table;
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
syscall_table_ptr_pro = &s_stub_table;
|
syscall_table_ptr_pro = &s_stub_table;
|
||||||
#else
|
#else
|
||||||
syscall_table_ptr = &s_stub_table;
|
syscall_table_ptr = &s_stub_table;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(&__sglue, 0, sizeof(__sglue));
|
memset(&__sglue, 0, sizeof(__sglue));
|
||||||
_global_impure_ptr = _GLOBAL_REENT;
|
_global_impure_ptr = _GLOBAL_REENT;
|
||||||
|
|
||||||
/* Ensure that the initialization of sfp is prevented until esp_newlib_init_global_stdio() is explicitly invoked. */
|
/* Ensure that the initialization of sfp is prevented until esp_newlib_init_global_stdio() is explicitly invoked. */
|
||||||
_GLOBAL_REENT->__cleanup = esp_cleanup_r;
|
_GLOBAL_REENT->__cleanup = esp_cleanup_r;
|
||||||
_REENT_SDIDINIT(_GLOBAL_REENT) = 1;
|
_REENT_SDIDINIT(_GLOBAL_REENT) = 1;
|
||||||
|
|
||||||
environ = malloc(sizeof(char*));
|
environ = malloc(sizeof(char*));
|
||||||
if (environ == 0) {
|
if (environ == 0) {
|
||||||
// if allocation fails this early in startup process, there's nothing else other than to panic.
|
// if allocation fails this early in startup process, there's nothing else other than to panic.
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
environ[0] = NULL;
|
environ[0] = NULL;
|
||||||
|
|
||||||
esp_newlib_locks_init();
|
esp_newlib_locks_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_SYSTEM_INIT_FN(init_newlib, CORE, BIT(0), 102)
|
ESP_SYSTEM_INIT_FN(init_newlib, CORE, BIT(0), 102)
|
||||||
{
|
{
|
||||||
esp_newlib_init();
|
esp_newlib_init();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_setup_newlib_syscalls(void) __attribute__((alias("esp_newlib_init")));
|
void esp_setup_newlib_syscalls(void) __attribute__((alias("esp_newlib_init")));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postponed _GLOBAL_REENT stdio FPs initialization.
|
* Postponed _GLOBAL_REENT stdio FPs initialization.
|
||||||
*
|
*
|
||||||
* Can not be a part of esp_reent_init() because stdio device may not initialized yet.
|
* Can not be a part of esp_reent_init() because stdio device may not initialized yet.
|
||||||
*
|
*
|
||||||
* Called from startup code and FreeRTOS, not intended to be called from
|
* Called from startup code and FreeRTOS, not intended to be called from
|
||||||
* application code.
|
* application code.
|
||||||
*/
|
*/
|
||||||
void esp_newlib_init_global_stdio(const char *stdio_dev)
|
void esp_newlib_init_global_stdio(const char *stdio_dev)
|
||||||
{
|
{
|
||||||
if (stdio_dev == NULL) {
|
if (stdio_dev == NULL) {
|
||||||
_GLOBAL_REENT->__cleanup = NULL;
|
_GLOBAL_REENT->__cleanup = NULL;
|
||||||
_REENT_SDIDINIT(_GLOBAL_REENT) = 0;
|
_REENT_SDIDINIT(_GLOBAL_REENT) = 0;
|
||||||
__sinit(_GLOBAL_REENT);
|
__sinit(_GLOBAL_REENT);
|
||||||
_GLOBAL_REENT->__cleanup = esp_cleanup_r;
|
_GLOBAL_REENT->__cleanup = esp_cleanup_r;
|
||||||
_REENT_SDIDINIT(_GLOBAL_REENT) = 1;
|
_REENT_SDIDINIT(_GLOBAL_REENT) = 1;
|
||||||
} else {
|
} else {
|
||||||
_REENT_STDIN(_GLOBAL_REENT) = fopen(stdio_dev, "r");
|
_REENT_STDIN(_GLOBAL_REENT) = fopen(stdio_dev, "r");
|
||||||
_REENT_STDOUT(_GLOBAL_REENT) = fopen(stdio_dev, "w");
|
_REENT_STDOUT(_GLOBAL_REENT) = fopen(stdio_dev, "w");
|
||||||
_REENT_STDERR(_GLOBAL_REENT) = fopen(stdio_dev, "w");
|
_REENT_STDERR(_GLOBAL_REENT) = fopen(stdio_dev, "w");
|
||||||
#if ESP_ROM_NEEDS_SWSETUP_WORKAROUND
|
#if ESP_ROM_NEEDS_SWSETUP_WORKAROUND
|
||||||
/*
|
/*
|
||||||
- This workaround for printf functions using 32-bit time_t after the 64-bit time_t upgrade
|
- This workaround for printf functions using 32-bit time_t after the 64-bit time_t upgrade
|
||||||
- The 32-bit time_t usage is triggered through ROM Newlib functions printf related functions calling __swsetup_r() on
|
- The 32-bit time_t usage is triggered through ROM Newlib functions printf related functions calling __swsetup_r() on
|
||||||
the first call to a particular file pointer (i.e., stdin, stdout, stderr)
|
the first call to a particular file pointer (i.e., stdin, stdout, stderr)
|
||||||
- Thus, we call the toolchain version of __swsetup_r() now (before any printf calls are made) to setup all of the
|
- Thus, we call the toolchain version of __swsetup_r() now (before any printf calls are made) to setup all of the
|
||||||
file pointers. Thus, the ROM newlib code will never call the ROM version of __swsetup_r().
|
file pointers. Thus, the ROM newlib code will never call the ROM version of __swsetup_r().
|
||||||
- See IDFGH-7728 for more details
|
- See IDFGH-7728 for more details
|
||||||
*/
|
*/
|
||||||
extern int __swsetup_r(struct _reent *, FILE *);
|
extern int __swsetup_r(struct _reent *, FILE *);
|
||||||
__swsetup_r(_GLOBAL_REENT, _REENT_STDIN(_GLOBAL_REENT));
|
__swsetup_r(_GLOBAL_REENT, _REENT_STDIN(_GLOBAL_REENT));
|
||||||
__swsetup_r(_GLOBAL_REENT, _REENT_STDOUT(_GLOBAL_REENT));
|
__swsetup_r(_GLOBAL_REENT, _REENT_STDOUT(_GLOBAL_REENT));
|
||||||
__swsetup_r(_GLOBAL_REENT, _REENT_STDERR(_GLOBAL_REENT));
|
__swsetup_r(_GLOBAL_REENT, _REENT_STDERR(_GLOBAL_REENT));
|
||||||
#endif /* ESP_ROM_NEEDS_SWSETUP_WORKAROUND */
|
#endif /* ESP_ROM_NEEDS_SWSETUP_WORKAROUND */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_SYSTEM_INIT_FN(init_newlib_stdio, CORE, BIT(0), 115)
|
ESP_SYSTEM_INIT_FN(init_newlib_stdio, CORE, BIT(0), 115)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_VFS_SUPPORT_IO)
|
#if defined(CONFIG_VFS_SUPPORT_IO)
|
||||||
esp_newlib_init_global_stdio("/dev/console");
|
esp_newlib_init_global_stdio("/dev/console");
|
||||||
#else
|
#else
|
||||||
esp_newlib_init_global_stdio(NULL);
|
esp_newlib_init_global_stdio(NULL);
|
||||||
#endif
|
#endif
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook to force the linker to include this file
|
// Hook to force the linker to include this file
|
||||||
void newlib_include_init_funcs(void)
|
void newlib_include_init_funcs(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,43 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This header file wraps newlib's own unmodified assert.h and adds
|
/* This header file wraps newlib's own unmodified assert.h and adds
|
||||||
support for silent assertion failure.
|
support for silent assertion failure.
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <sdkconfig.h>
|
#include <sdkconfig.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include_next <assert.h>
|
#include_next <assert.h>
|
||||||
|
|
||||||
/* moved part of libc provided assert to here allows
|
/* moved part of libc provided assert to here allows
|
||||||
* tweaking the assert macro to use __builtin_expect()
|
* tweaking the assert macro to use __builtin_expect()
|
||||||
* and reduce jumps in the "asserts OK" code path
|
* and reduce jumps in the "asserts OK" code path
|
||||||
*
|
*
|
||||||
* Note: using __builtin_expect() not likely() to avoid defining the likely
|
* Note: using __builtin_expect() not likely() to avoid defining the likely
|
||||||
* macro in namespace of non-IDF code that may include this standard header.
|
* macro in namespace of non-IDF code that may include this standard header.
|
||||||
*/
|
*/
|
||||||
#undef assert
|
#undef assert
|
||||||
|
|
||||||
/* __FILENAME__ points to the file name instead of path + filename
|
/* __FILENAME__ points to the file name instead of path + filename
|
||||||
* e.g __FILE__ points to "/apps/test.c" where as __FILENAME__ points to "test.c"
|
* e.g __FILE__ points to "/apps/test.c" where as __FILENAME__ points to "test.c"
|
||||||
*/
|
*/
|
||||||
#define __FILENAME__ (__builtin_strrchr( "/" __FILE__, '/') + 1)
|
#define __FILENAME__ (__builtin_strrchr( "/" __FILE__, '/') + 1)
|
||||||
|
|
||||||
#if defined(NDEBUG)
|
#if defined(NDEBUG)
|
||||||
|
|
||||||
#define assert(__e) ((void)(__e))
|
#define assert(__e) ((void)(__e))
|
||||||
|
|
||||||
#elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
#elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
||||||
|
|
||||||
#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(NULL, 0, NULL, NULL))
|
#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(NULL, 0, NULL, NULL))
|
||||||
|
|
||||||
#else // !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
#else // !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
||||||
|
|
||||||
#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILENAME__, __LINE__, \
|
#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILENAME__, __LINE__, \
|
||||||
__ASSERT_FUNC, #__e))
|
__ASSERT_FUNC, #__e))
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,208 +1,208 @@
|
|||||||
/*
|
/*
|
||||||
* All the code below is a rework of
|
* All the code below is a rework of
|
||||||
* https://github.com/freebsd/freebsd/blob/master/sys/sys/endian.h
|
* https://github.com/freebsd/freebsd/blob/master/sys/sys/endian.h
|
||||||
* to import symbols defining non-standard endian handling functions.
|
* to import symbols defining non-standard endian handling functions.
|
||||||
* The aforementioned source code license terms are included here.
|
* The aforementioned source code license terms are included here.
|
||||||
* For further license info, please look at https://github.com/freebsd/freebsd
|
* For further license info, please look at https://github.com/freebsd/freebsd
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
* SPDX-FileCopyrightText: 2020 Francesco Giancane <francesco.giancane@accenture.com>
|
* SPDX-FileCopyrightText: 2020 Francesco Giancane <francesco.giancane@accenture.com>
|
||||||
* SPDX-FileCopyrightText: 2002 Thomas Moestl <tmm@FreeBSD.org>
|
* SPDX-FileCopyrightText: 2002 Thomas Moestl <tmm@FreeBSD.org>
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND Apache-2.0
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND Apache-2.0
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
|
* Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a compatibility header for <endian.h>.
|
* This is a compatibility header for <endian.h>.
|
||||||
* In xtensa-newlib distribution it is located in <machine/endian.h>
|
* In xtensa-newlib distribution it is located in <machine/endian.h>
|
||||||
* but most program expect to be plain <endian.h>.
|
* but most program expect to be plain <endian.h>.
|
||||||
*/
|
*/
|
||||||
#include <machine/endian.h>
|
#include <machine/endian.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General byte order swapping functions.
|
* General byte order swapping functions.
|
||||||
*/
|
*/
|
||||||
#define bswap16(x) __bswap16(x)
|
#define bswap16(x) __bswap16(x)
|
||||||
#define bswap32(x) __bswap32(x)
|
#define bswap32(x) __bswap32(x)
|
||||||
#define bswap64(x) __bswap64(x)
|
#define bswap64(x) __bswap64(x)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Host to big endian, host to little endian, big endian to host, and little
|
* Host to big endian, host to little endian, big endian to host, and little
|
||||||
* endian to host byte order functions as detailed in byteorder(9).
|
* endian to host byte order functions as detailed in byteorder(9).
|
||||||
*/
|
*/
|
||||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||||
#define htobe16(x) bswap16((x))
|
#define htobe16(x) bswap16((x))
|
||||||
#define htobe32(x) bswap32((x))
|
#define htobe32(x) bswap32((x))
|
||||||
#define htobe64(x) bswap64((x))
|
#define htobe64(x) bswap64((x))
|
||||||
#define htole16(x) ((uint16_t)(x))
|
#define htole16(x) ((uint16_t)(x))
|
||||||
#define htole32(x) ((uint32_t)(x))
|
#define htole32(x) ((uint32_t)(x))
|
||||||
#define htole64(x) ((uint64_t)(x))
|
#define htole64(x) ((uint64_t)(x))
|
||||||
|
|
||||||
#define be16toh(x) bswap16((x))
|
#define be16toh(x) bswap16((x))
|
||||||
#define be32toh(x) bswap32((x))
|
#define be32toh(x) bswap32((x))
|
||||||
#define be64toh(x) bswap64((x))
|
#define be64toh(x) bswap64((x))
|
||||||
#define le16toh(x) ((uint16_t)(x))
|
#define le16toh(x) ((uint16_t)(x))
|
||||||
#define le32toh(x) ((uint32_t)(x))
|
#define le32toh(x) ((uint32_t)(x))
|
||||||
#define le64toh(x) ((uint64_t)(x))
|
#define le64toh(x) ((uint64_t)(x))
|
||||||
#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
|
#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
|
||||||
#define htobe16(x) ((uint16_t)(x))
|
#define htobe16(x) ((uint16_t)(x))
|
||||||
#define htobe32(x) ((uint32_t)(x))
|
#define htobe32(x) ((uint32_t)(x))
|
||||||
#define htobe64(x) ((uint64_t)(x))
|
#define htobe64(x) ((uint64_t)(x))
|
||||||
#define htole16(x) bswap16((x))
|
#define htole16(x) bswap16((x))
|
||||||
#define htole32(x) bswap32((x))
|
#define htole32(x) bswap32((x))
|
||||||
#define htole64(x) bswap64((x))
|
#define htole64(x) bswap64((x))
|
||||||
|
|
||||||
#define be16toh(x) ((uint16_t)(x))
|
#define be16toh(x) ((uint16_t)(x))
|
||||||
#define be32toh(x) ((uint32_t)(x))
|
#define be32toh(x) ((uint32_t)(x))
|
||||||
#define be64toh(x) ((uint64_t)(x))
|
#define be64toh(x) ((uint64_t)(x))
|
||||||
#define le16toh(x) bswap16((x))
|
#define le16toh(x) bswap16((x))
|
||||||
#define le32toh(x) bswap32((x))
|
#define le32toh(x) bswap32((x))
|
||||||
#define le64toh(x) bswap64((x))
|
#define le64toh(x) bswap64((x))
|
||||||
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
|
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
|
||||||
|
|
||||||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
|
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
|
||||||
|
|
||||||
static __inline uint16_t
|
static __inline uint16_t
|
||||||
be16dec(const void *pp)
|
be16dec(const void *pp)
|
||||||
{
|
{
|
||||||
uint8_t const *p = (uint8_t const *)pp;
|
uint8_t const *p = (uint8_t const *)pp;
|
||||||
|
|
||||||
return ((p[0] << 8) | p[1]);
|
return ((p[0] << 8) | p[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint32_t
|
static __inline uint32_t
|
||||||
be32dec(const void *pp)
|
be32dec(const void *pp)
|
||||||
{
|
{
|
||||||
uint8_t const *p = (uint8_t const *)pp;
|
uint8_t const *p = (uint8_t const *)pp;
|
||||||
|
|
||||||
return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint64_t
|
static __inline uint64_t
|
||||||
be64dec(const void *pp)
|
be64dec(const void *pp)
|
||||||
{
|
{
|
||||||
uint8_t const *p = (uint8_t const *)pp;
|
uint8_t const *p = (uint8_t const *)pp;
|
||||||
|
|
||||||
return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
|
return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t
|
static __inline uint16_t
|
||||||
le16dec(const void *pp)
|
le16dec(const void *pp)
|
||||||
{
|
{
|
||||||
uint8_t const *p = (uint8_t const *)pp;
|
uint8_t const *p = (uint8_t const *)pp;
|
||||||
|
|
||||||
return ((p[1] << 8) | p[0]);
|
return ((p[1] << 8) | p[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint32_t
|
static __inline uint32_t
|
||||||
le32dec(const void *pp)
|
le32dec(const void *pp)
|
||||||
{
|
{
|
||||||
uint8_t const *p = (uint8_t const *)pp;
|
uint8_t const *p = (uint8_t const *)pp;
|
||||||
|
|
||||||
return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint64_t
|
static __inline uint64_t
|
||||||
le64dec(const void *pp)
|
le64dec(const void *pp)
|
||||||
{
|
{
|
||||||
uint8_t const *p = (uint8_t const *)pp;
|
uint8_t const *p = (uint8_t const *)pp;
|
||||||
|
|
||||||
return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
|
return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
be16enc(void *pp, uint16_t u)
|
be16enc(void *pp, uint16_t u)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t *)pp;
|
uint8_t *p = (uint8_t *)pp;
|
||||||
|
|
||||||
p[0] = (u >> 8) & 0xff;
|
p[0] = (u >> 8) & 0xff;
|
||||||
p[1] = u & 0xff;
|
p[1] = u & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
be32enc(void *pp, uint32_t u)
|
be32enc(void *pp, uint32_t u)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t *)pp;
|
uint8_t *p = (uint8_t *)pp;
|
||||||
|
|
||||||
p[0] = (u >> 24) & 0xff;
|
p[0] = (u >> 24) & 0xff;
|
||||||
p[1] = (u >> 16) & 0xff;
|
p[1] = (u >> 16) & 0xff;
|
||||||
p[2] = (u >> 8) & 0xff;
|
p[2] = (u >> 8) & 0xff;
|
||||||
p[3] = u & 0xff;
|
p[3] = u & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
be64enc(void *pp, uint64_t u)
|
be64enc(void *pp, uint64_t u)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t *)pp;
|
uint8_t *p = (uint8_t *)pp;
|
||||||
|
|
||||||
be32enc(p, (uint32_t)(u >> 32));
|
be32enc(p, (uint32_t)(u >> 32));
|
||||||
be32enc(p + 4, (uint32_t)(u & 0xffffffffU));
|
be32enc(p + 4, (uint32_t)(u & 0xffffffffU));
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
le16enc(void *pp, uint16_t u)
|
le16enc(void *pp, uint16_t u)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t *)pp;
|
uint8_t *p = (uint8_t *)pp;
|
||||||
|
|
||||||
p[0] = u & 0xff;
|
p[0] = u & 0xff;
|
||||||
p[1] = (u >> 8) & 0xff;
|
p[1] = (u >> 8) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
le32enc(void *pp, uint32_t u)
|
le32enc(void *pp, uint32_t u)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t *)pp;
|
uint8_t *p = (uint8_t *)pp;
|
||||||
|
|
||||||
p[0] = u & 0xff;
|
p[0] = u & 0xff;
|
||||||
p[1] = (u >> 8) & 0xff;
|
p[1] = (u >> 8) & 0xff;
|
||||||
p[2] = (u >> 16) & 0xff;
|
p[2] = (u >> 16) & 0xff;
|
||||||
p[3] = (u >> 24) & 0xff;
|
p[3] = (u >> 24) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
le64enc(void *pp, uint64_t u)
|
le64enc(void *pp, uint64_t u)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t *)pp;
|
uint8_t *p = (uint8_t *)pp;
|
||||||
|
|
||||||
le32enc(p, (uint32_t)(u & 0xffffffffU));
|
le32enc(p, (uint32_t)(u & 0xffffffffU));
|
||||||
le32enc(p + 4, (uint32_t)(u >> 32));
|
le32enc(p + 4, (uint32_t)(u >> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef _ESP_PLATFORM_ERRNO_H_
|
#ifndef _ESP_PLATFORM_ERRNO_H_
|
||||||
#define _ESP_PLATFORM_ERRNO_H_
|
#define _ESP_PLATFORM_ERRNO_H_
|
||||||
|
|
||||||
#include_next "errno.h"
|
#include_next "errno.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Possibly define some missing errors
|
// Possibly define some missing errors
|
||||||
//
|
//
|
||||||
#ifndef ESHUTDOWN
|
#ifndef ESHUTDOWN
|
||||||
#define ESHUTDOWN 110 /* Cannot send after transport endpoint shutdown */
|
#define ESHUTDOWN 110 /* Cannot send after transport endpoint shutdown */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EAI_SOCKTYPE
|
#ifndef EAI_SOCKTYPE
|
||||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EAI_AGAIN
|
#ifndef EAI_AGAIN
|
||||||
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EAI_BADFLAGS
|
#ifndef EAI_BADFLAGS
|
||||||
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _ESP_PLATFORM_ERRNO_H_
|
#endif // _ESP_PLATFORM_ERRNO_H_
|
||||||
|
|||||||
@@ -1,76 +1,76 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize newlib time functions
|
* Initialize newlib time functions
|
||||||
*/
|
*/
|
||||||
void esp_newlib_time_init(void);
|
void esp_newlib_time_init(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for newlib's _REENT_INIT_PTR and __sinit.
|
* Replacement for newlib's _REENT_INIT_PTR and __sinit.
|
||||||
*
|
*
|
||||||
* Called from startup code and FreeRTOS, not intended to be called from
|
* Called from startup code and FreeRTOS, not intended to be called from
|
||||||
* application code.
|
* application code.
|
||||||
*/
|
*/
|
||||||
void esp_reent_init(struct _reent* r);
|
void esp_reent_init(struct _reent* r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postponed _GLOBAL_REENT stdio FPs initialization.
|
* Postponed _GLOBAL_REENT stdio FPs initialization.
|
||||||
*
|
*
|
||||||
* Can not be a part of esp_reent_init() because stdio device may not initialized yet.
|
* Can not be a part of esp_reent_init() because stdio device may not initialized yet.
|
||||||
*
|
*
|
||||||
* Called from startup code and FreeRTOS, not intended to be called from
|
* Called from startup code and FreeRTOS, not intended to be called from
|
||||||
* application code.
|
* application code.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void esp_newlib_init_global_stdio(const char* stdio_dev);
|
void esp_newlib_init_global_stdio(const char* stdio_dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up some of lazily allocated buffers in REENT structures.
|
* Clean up some of lazily allocated buffers in REENT structures.
|
||||||
*/
|
*/
|
||||||
void esp_reent_cleanup(void);
|
void esp_reent_cleanup(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function which sets up newlib in ROM for use with ESP-IDF
|
* Function which sets up newlib in ROM for use with ESP-IDF
|
||||||
*
|
*
|
||||||
* Includes defining the syscall table, setting up any common locks, etc.
|
* Includes defining the syscall table, setting up any common locks, etc.
|
||||||
*
|
*
|
||||||
* Called from the startup code, not intended to be called from application
|
* Called from the startup code, not intended to be called from application
|
||||||
* code.
|
* code.
|
||||||
*/
|
*/
|
||||||
void esp_newlib_init(void);
|
void esp_newlib_init(void);
|
||||||
|
|
||||||
void esp_setup_syscall_table(void) __attribute__((deprecated("Please call esp_newlib_init() in newer code")));
|
void esp_setup_syscall_table(void) __attribute__((deprecated("Please call esp_newlib_init() in newer code")));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update current microsecond time from RTC
|
* Update current microsecond time from RTC
|
||||||
*/
|
*/
|
||||||
void esp_set_time_from_rtc(void);
|
void esp_set_time_from_rtc(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sync timekeeping timers, RTC and high-resolution timer. Update boot_time.
|
* Sync timekeeping timers, RTC and high-resolution timer. Update boot_time.
|
||||||
*/
|
*/
|
||||||
void esp_sync_timekeeping_timers(void);
|
void esp_sync_timekeeping_timers(void);
|
||||||
|
|
||||||
/* Kept for backward compatibility */
|
/* Kept for backward compatibility */
|
||||||
#define esp_sync_counters_rtc_and_frc esp_sync_timekeeping_timers
|
#define esp_sync_counters_rtc_and_frc esp_sync_timekeeping_timers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize newlib static locks
|
* Initialize newlib static locks
|
||||||
*/
|
*/
|
||||||
void esp_newlib_locks_init(void);
|
void esp_newlib_locks_init(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef _ESP_PLATFORM_NET_IF_H_
|
#ifndef _ESP_PLATFORM_NET_IF_H_
|
||||||
#define _ESP_PLATFORM_NET_IF_H_
|
#define _ESP_PLATFORM_NET_IF_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lwip/sockets.h"
|
#include "lwip/sockets.h"
|
||||||
#include "lwip/if_api.h"
|
#include "lwip/if_api.h"
|
||||||
|
|
||||||
#define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
#define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
||||||
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
||||||
#define MSG_EOR 0x8 /* data completes record */
|
#define MSG_EOR 0x8 /* data completes record */
|
||||||
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
#define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
||||||
#define SOMAXCONN 128
|
#define SOMAXCONN 128
|
||||||
|
|
||||||
#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
|
#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
|
||||||
|
|
||||||
#define NI_MAXHOST 1025
|
#define NI_MAXHOST 1025
|
||||||
#define NI_MAXSERV 32
|
#define NI_MAXSERV 32
|
||||||
#define NI_NUMERICSERV 0x00000008
|
#define NI_NUMERICSERV 0x00000008
|
||||||
#define NI_DGRAM 0x00000010
|
#define NI_DGRAM 0x00000010
|
||||||
|
|
||||||
typedef u32_t socklen_t;
|
typedef u32_t socklen_t;
|
||||||
|
|
||||||
unsigned int if_nametoindex(const char *ifname);
|
unsigned int if_nametoindex(const char *ifname);
|
||||||
|
|
||||||
char *if_indextoname(unsigned int ifindex, char *ifname);
|
char *if_indextoname(unsigned int ifindex, char *ifname);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _ESP_PLATFORM_NET_IF_H_
|
#endif // _ESP_PLATFORM_NET_IF_H_
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifndef __ESP_PLATFORM_PTHREAD_H__
|
#ifndef __ESP_PLATFORM_PTHREAD_H__
|
||||||
#define __ESP_PLATFORM_PTHREAD_H__
|
#define __ESP_PLATFORM_PTHREAD_H__
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/features.h>
|
#include <sys/features.h>
|
||||||
|
|
||||||
#include_next <pthread.h>
|
#include_next <pthread.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pthread_condattr_getclock(const pthread_condattr_t * attr, clockid_t * clock_id);
|
int pthread_condattr_getclock(const pthread_condattr_t * attr, clockid_t * clock_id);
|
||||||
|
|
||||||
int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id);
|
int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // __ESP_PLATFORM_PTHREAD_H__
|
#endif // __ESP_PLATFORM_PTHREAD_H__
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned int sem_t;
|
typedef unsigned int sem_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the maximum value to which any POSIX semaphore can count on ESP chips.
|
* This is the maximum value to which any POSIX semaphore can count on ESP chips.
|
||||||
*/
|
*/
|
||||||
#define SEM_VALUE_MAX 0x7FFF
|
#define SEM_VALUE_MAX 0x7FFF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*
|
*
|
||||||
* Must NOT be called if threads are still blocked on semaphore!
|
* Must NOT be called if threads are still blocked on semaphore!
|
||||||
*/
|
*/
|
||||||
int sem_destroy(sem_t *sem);
|
int sem_destroy(sem_t *sem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*
|
*
|
||||||
* Note that on ESP chips, pshared is ignored. Semaphores can always be shared between FreeRTOS tasks.
|
* Note that on ESP chips, pshared is ignored. Semaphores can always be shared between FreeRTOS tasks.
|
||||||
*/
|
*/
|
||||||
int sem_init(sem_t *sem, int pshared, unsigned value);
|
int sem_init(sem_t *sem, int pshared, unsigned value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*
|
*
|
||||||
* Note that, unlike specified in POSIX, this implementation returns -1 and sets errno to
|
* Note that, unlike specified in POSIX, this implementation returns -1 and sets errno to
|
||||||
* EAGAIN if the semaphore can not be unlocked (posted) due to its value being SEM_VALUE_MAX.
|
* EAGAIN if the semaphore can not be unlocked (posted) due to its value being SEM_VALUE_MAX.
|
||||||
*/
|
*/
|
||||||
int sem_post(sem_t *sem);
|
int sem_post(sem_t *sem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*
|
*
|
||||||
* Note the following three deviations/issues originating from the underlying FreeRTOS implementation:
|
* Note the following three deviations/issues originating from the underlying FreeRTOS implementation:
|
||||||
* * The time value passed by abstime will be rounded up to the next FreeRTOS tick.
|
* * The time value passed by abstime will be rounded up to the next FreeRTOS tick.
|
||||||
* * The actual timeout will happen after the tick the time was rounded to
|
* * The actual timeout will happen after the tick the time was rounded to
|
||||||
* and before the following tick.
|
* and before the following tick.
|
||||||
* * It is possible, though unlikely, that the task is preempted directly after the timeout calculation,
|
* * It is possible, though unlikely, that the task is preempted directly after the timeout calculation,
|
||||||
* delaying timeout of the following blocking operating system call by the duration of the preemption.
|
* delaying timeout of the following blocking operating system call by the duration of the preemption.
|
||||||
*/
|
*/
|
||||||
int sem_timedwait(sem_t *semaphore, const struct timespec *abstime);
|
int sem_timedwait(sem_t *semaphore, const struct timespec *abstime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*/
|
*/
|
||||||
int sem_trywait(sem_t *sem);
|
int sem_trywait(sem_t *sem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*/
|
*/
|
||||||
int sem_wait(sem_t *sem);
|
int sem_wait(sem_t *sem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
* This is a POSIX function, please refer to the POSIX specification for a detailed description.
|
||||||
*/
|
*/
|
||||||
int sem_getvalue(sem_t *sem, int *sval);
|
int sem_getvalue(sem_t *sem, int *sval);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,70 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#ifdef __clang__ // TODO LLVM-330
|
#ifdef __clang__ // TODO LLVM-330
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This header file provides POSIX-compatible definitions of directory
|
* This header file provides POSIX-compatible definitions of directory
|
||||||
* access data types. Starting with newlib 3.3, related functions are defined
|
* access data types. Starting with newlib 3.3, related functions are defined
|
||||||
* in 'dirent.h' bundled with newlib.
|
* in 'dirent.h' bundled with newlib.
|
||||||
* See http://pubs.opengroup.org/onlinepubs/7908799/xsh/dirent.h.html
|
* See http://pubs.opengroup.org/onlinepubs/7908799/xsh/dirent.h.html
|
||||||
* for reference.
|
* for reference.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Opaque directory structure
|
* @brief Opaque directory structure
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t dd_vfs_idx; /*!< VFS index, not to be used by applications */
|
uint16_t dd_vfs_idx; /*!< VFS index, not to be used by applications */
|
||||||
uint16_t dd_rsv; /*!< field reserved for future extension */
|
uint16_t dd_rsv; /*!< field reserved for future extension */
|
||||||
/* remaining fields are defined by VFS implementation */
|
/* remaining fields are defined by VFS implementation */
|
||||||
} DIR;
|
} DIR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Directory entry structure
|
* @brief Directory entry structure
|
||||||
*/
|
*/
|
||||||
struct dirent {
|
struct dirent {
|
||||||
ino_t d_ino; /*!< file number */
|
ino_t d_ino; /*!< file number */
|
||||||
uint8_t d_type; /*!< not defined in POSIX, but present in BSD and Linux */
|
uint8_t d_type; /*!< not defined in POSIX, but present in BSD and Linux */
|
||||||
#define DT_UNKNOWN 0
|
#define DT_UNKNOWN 0
|
||||||
#define DT_REG 1
|
#define DT_REG 1
|
||||||
#define DT_DIR 2
|
#define DT_DIR 2
|
||||||
#if __BSD_VISIBLE
|
#if __BSD_VISIBLE
|
||||||
#define MAXNAMLEN 255
|
#define MAXNAMLEN 255
|
||||||
char d_name[MAXNAMLEN + 1]; /*!< zero-terminated file name */
|
char d_name[MAXNAMLEN + 1]; /*!< zero-terminated file name */
|
||||||
#else
|
#else
|
||||||
char d_name[256];
|
char d_name[256];
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
DIR* opendir(const char* name);
|
DIR* opendir(const char* name);
|
||||||
struct dirent* readdir(DIR* pdir);
|
struct dirent* readdir(DIR* pdir);
|
||||||
long telldir(DIR* pdir);
|
long telldir(DIR* pdir);
|
||||||
void seekdir(DIR* pdir, long loc);
|
void seekdir(DIR* pdir, long loc);
|
||||||
void rewinddir(DIR* pdir);
|
void rewinddir(DIR* pdir);
|
||||||
int closedir(DIR* pdir);
|
int closedir(DIR* pdir);
|
||||||
int readdir_r(DIR* pdir, struct dirent* entry, struct dirent** out_dirent);
|
int readdir_r(DIR* pdir, struct dirent* entry, struct dirent** out_dirent);
|
||||||
int scandir(const char *dirname, struct dirent ***out_dirlist,
|
int scandir(const char *dirname, struct dirent ***out_dirlist,
|
||||||
int (*select_func)(const struct dirent *),
|
int (*select_func)(const struct dirent *),
|
||||||
int (*cmp_func)(const struct dirent **, const struct dirent **));
|
int (*cmp_func)(const struct dirent **, const struct dirent **));
|
||||||
int alphasort(const struct dirent **d1, const struct dirent **d2);
|
int alphasort(const struct dirent **d1, const struct dirent **d2);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else // __clang__ TODO: IDF-10675
|
#else // __clang__ TODO: IDF-10675
|
||||||
#include_next <sys/dirent.h>
|
#include_next <sys/dirent.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif // __clang__
|
#endif // __clang__
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ioctl(int fd, int request, ...);
|
int ioctl(int fd, int request, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include_next <sys/lock.h>
|
#include_next <sys/lock.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#ifdef _RETARGETABLE_LOCKING
|
#ifdef _RETARGETABLE_LOCKING
|
||||||
|
|
||||||
/* Actual platfrom-specific definition of struct __lock.
|
/* Actual platfrom-specific definition of struct __lock.
|
||||||
* The size here should be sufficient for a FreeRTOS mutex.
|
* The size here should be sufficient for a FreeRTOS mutex.
|
||||||
* This is checked by a static assertion in locks.c
|
* This is checked by a static assertion in locks.c
|
||||||
*
|
*
|
||||||
* Note: this might need to be made dependent on whether FreeRTOS
|
* Note: this might need to be made dependent on whether FreeRTOS
|
||||||
* is included in the build.
|
* is included in the build.
|
||||||
*/
|
*/
|
||||||
struct __lock {
|
struct __lock {
|
||||||
#if (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
#if (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
||||||
int reserved[29];
|
int reserved[29];
|
||||||
#elif (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && !CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
#elif (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && !CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
||||||
int reserved[27];
|
int reserved[27];
|
||||||
#elif (!CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
#elif (!CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
||||||
int reserved[23];
|
int reserved[23];
|
||||||
#else
|
#else
|
||||||
int reserved[21];
|
int reserved[21];
|
||||||
#endif /* #if (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY) */
|
#endif /* #if (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Compatibility definitions for the legacy ESP-specific locking implementation.
|
/* Compatibility definitions for the legacy ESP-specific locking implementation.
|
||||||
* These used to be provided by libc/sys/xtensa/sys/lock.h in newlib.
|
* These used to be provided by libc/sys/xtensa/sys/lock.h in newlib.
|
||||||
* Newer versions of newlib don't have this ESP-specific lock.h header, and are
|
* Newer versions of newlib don't have this ESP-specific lock.h header, and are
|
||||||
* built with _RETARGETABLE_LOCKING enabled, instead.
|
* built with _RETARGETABLE_LOCKING enabled, instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef _LOCK_T _lock_t;
|
typedef _LOCK_T _lock_t;
|
||||||
|
|
||||||
void _lock_init(_lock_t *plock);
|
void _lock_init(_lock_t *plock);
|
||||||
void _lock_init_recursive(_lock_t *plock);
|
void _lock_init_recursive(_lock_t *plock);
|
||||||
void _lock_close(_lock_t *plock);
|
void _lock_close(_lock_t *plock);
|
||||||
void _lock_close_recursive(_lock_t *plock);
|
void _lock_close_recursive(_lock_t *plock);
|
||||||
void _lock_acquire(_lock_t *plock);
|
void _lock_acquire(_lock_t *plock);
|
||||||
void _lock_acquire_recursive(_lock_t *plock);
|
void _lock_acquire_recursive(_lock_t *plock);
|
||||||
int _lock_try_acquire(_lock_t *plock);
|
int _lock_try_acquire(_lock_t *plock);
|
||||||
int _lock_try_acquire_recursive(_lock_t *plock);
|
int _lock_try_acquire_recursive(_lock_t *plock);
|
||||||
void _lock_release(_lock_t *plock);
|
void _lock_release(_lock_t *plock);
|
||||||
void _lock_release_recursive(_lock_t *plock);
|
void _lock_release_recursive(_lock_t *plock);
|
||||||
|
|
||||||
#endif // _RETARGETABLE_LOCKING
|
#endif // _RETARGETABLE_LOCKING
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ESP_PLATFORM_SYS_POLL_H_
|
#ifndef _ESP_PLATFORM_SYS_POLL_H_
|
||||||
#define _ESP_PLATFORM_SYS_POLL_H_
|
#define _ESP_PLATFORM_SYS_POLL_H_
|
||||||
|
|
||||||
#define POLLIN (1u << 0) /* data other than high-priority may be read without blocking */
|
#define POLLIN (1u << 0) /* data other than high-priority may be read without blocking */
|
||||||
#define POLLRDNORM (1u << 1) /* normal data may be read without blocking */
|
#define POLLRDNORM (1u << 1) /* normal data may be read without blocking */
|
||||||
#define POLLRDBAND (1u << 2) /* priority data may be read without blocking */
|
#define POLLRDBAND (1u << 2) /* priority data may be read without blocking */
|
||||||
#define POLLPRI (POLLRDBAND) /* high-priority data may be read without blocking */
|
#define POLLPRI (POLLRDBAND) /* high-priority data may be read without blocking */
|
||||||
// Note: POLLPRI is made equivalent to POLLRDBAND in order to fit all these events into one byte
|
// Note: POLLPRI is made equivalent to POLLRDBAND in order to fit all these events into one byte
|
||||||
#define POLLOUT (1u << 3) /* normal data may be written without blocking */
|
#define POLLOUT (1u << 3) /* normal data may be written without blocking */
|
||||||
#define POLLWRNORM (POLLOUT) /* equivalent to POLLOUT */
|
#define POLLWRNORM (POLLOUT) /* equivalent to POLLOUT */
|
||||||
#define POLLWRBAND (1u << 4) /* priority data my be written */
|
#define POLLWRBAND (1u << 4) /* priority data my be written */
|
||||||
#define POLLERR (1u << 5) /* some poll error occurred */
|
#define POLLERR (1u << 5) /* some poll error occurred */
|
||||||
#define POLLHUP (1u << 6) /* file descriptor was "hung up" */
|
#define POLLHUP (1u << 6) /* file descriptor was "hung up" */
|
||||||
#define POLLNVAL (1u << 7) /* the specified file descriptor is invalid */
|
#define POLLNVAL (1u << 7) /* the specified file descriptor is invalid */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct pollfd {
|
struct pollfd {
|
||||||
int fd; /* The descriptor. */
|
int fd; /* The descriptor. */
|
||||||
short events; /* The event(s) is/are specified here. */
|
short events; /* The event(s) is/are specified here. */
|
||||||
short revents; /* Events found are returned here. */
|
short revents; /* Events found are returned here. */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned int nfds_t;
|
typedef unsigned int nfds_t;
|
||||||
|
|
||||||
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _ESP_PLATFORM_SYS_POLL_H_
|
#endif // _ESP_PLATFORM_SYS_POLL_H_
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SYS_RANDOM__
|
#ifndef __SYS_RANDOM__
|
||||||
#define __SYS_RANDOM__
|
#define __SYS_RANDOM__
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
|
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //__SYS_RANDOM__
|
#endif //__SYS_RANDOM__
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define _REENT_BACKWARD_BINARY_COMPAT
|
#define _REENT_BACKWARD_BINARY_COMPAT
|
||||||
#define _REENT_SDIDINIT(_ptr) ((_ptr)->_reserved_0)
|
#define _REENT_SDIDINIT(_ptr) ((_ptr)->_reserved_0)
|
||||||
#define _REENT_SGLUE(_ptr) (__sglue)
|
#define _REENT_SGLUE(_ptr) (__sglue)
|
||||||
|
|
||||||
#include_next<sys/reent.h>
|
#include_next<sys/reent.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void __sinit(struct _reent *);
|
extern void __sinit(struct _reent *);
|
||||||
|
|
||||||
extern struct _glue __sglue;
|
extern struct _glue __sglue;
|
||||||
extern struct _reent * _global_impure_ptr;
|
extern struct _reent * _global_impure_ptr;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,42 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ESP_SYS_SELECT_H__
|
#ifndef __ESP_SYS_SELECT_H__
|
||||||
#define __ESP_SYS_SELECT_H__
|
#define __ESP_SYS_SELECT_H__
|
||||||
|
|
||||||
/* Newlib 2.2.0 does not provide sys/select.h, and fd_set is defined in sys/types.h */
|
/* Newlib 2.2.0 does not provide sys/select.h, and fd_set is defined in sys/types.h */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifndef fd_set
|
#ifndef fd_set
|
||||||
#include_next <sys/select.h>
|
#include_next <sys/select.h>
|
||||||
#else // fd_set
|
#else // fd_set
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
|
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // fd_set
|
#endif // fd_set
|
||||||
|
|
||||||
#if defined(FD_ISSET) || defined(FD_SET) || defined(FD_CLR)
|
#if defined(FD_ISSET) || defined(FD_SET) || defined(FD_CLR)
|
||||||
#undef FD_SET
|
#undef FD_SET
|
||||||
#undef FD_CLR
|
#undef FD_CLR
|
||||||
#undef FD_ISSET
|
#undef FD_ISSET
|
||||||
|
|
||||||
#define __FD_SAFE_SET(n, code) do { if ((unsigned)(n) < FD_SETSIZE) { code; } } while(0)
|
#define __FD_SAFE_SET(n, code) do { if ((unsigned)(n) < FD_SETSIZE) { code; } } while(0)
|
||||||
#define __FD_SAFE_GET(n, code) (((unsigned)(n) < FD_SETSIZE) ? (code) : 0)
|
#define __FD_SAFE_GET(n, code) (((unsigned)(n) < FD_SETSIZE) ? (code) : 0)
|
||||||
|
|
||||||
#define FD_SET(n, p) __FD_SAFE_SET(n, ((p)->fds_bits[(n) / NFDBITS] |= (1L << ((n) % NFDBITS))))
|
#define FD_SET(n, p) __FD_SAFE_SET(n, ((p)->fds_bits[(n) / NFDBITS] |= (1L << ((n) % NFDBITS))))
|
||||||
#define FD_CLR(n, p) __FD_SAFE_SET(n, ((p)->fds_bits[(n) / NFDBITS] &= ~(1L << ((n) % NFDBITS))))
|
#define FD_CLR(n, p) __FD_SAFE_SET(n, ((p)->fds_bits[(n) / NFDBITS] &= ~(1L << ((n) % NFDBITS))))
|
||||||
#define FD_ISSET(n, p) __FD_SAFE_GET(n, ((p)->fds_bits[(n) / NFDBITS] & (1L << ((n) % NFDBITS))))
|
#define FD_ISSET(n, p) __FD_SAFE_GET(n, ((p)->fds_bits[(n) / NFDBITS] & (1L << ((n) % NFDBITS))))
|
||||||
#endif // FD_ISSET || FD_SET || FD_CLR
|
#endif // FD_ISSET || FD_SET || FD_CLR
|
||||||
|
|
||||||
#endif //__ESP_SYS_SELECT_H__
|
#endif //__ESP_SYS_SELECT_H__
|
||||||
|
|||||||
@@ -1,286 +1,286 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
// This header file is based on the termios header of
|
// This header file is based on the termios header of
|
||||||
// "The Single UNIX (r) Specification, Version 2, Copyright (c) 1997 The Open Group".
|
// "The Single UNIX (r) Specification, Version 2, Copyright (c) 1997 The Open Group".
|
||||||
|
|
||||||
#ifndef __ESP_SYS_TERMIOS_H__
|
#ifndef __ESP_SYS_TERMIOS_H__
|
||||||
#define __ESP_SYS_TERMIOS_H__
|
#define __ESP_SYS_TERMIOS_H__
|
||||||
|
|
||||||
// ESP-IDF NOTE: This header provides only a compatibility layer for macros and functions defined in sys/termios.h.
|
// ESP-IDF NOTE: This header provides only a compatibility layer for macros and functions defined in sys/termios.h.
|
||||||
// Not everything has a defined meaning for ESP-IDF (e.g. process leader IDs) and therefore are likely to be stubbed
|
// Not everything has a defined meaning for ESP-IDF (e.g. process leader IDs) and therefore are likely to be stubbed
|
||||||
// in actual implementations.
|
// in actual implementations.
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
|
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
|
|
||||||
// subscripts for the array c_cc:
|
// subscripts for the array c_cc:
|
||||||
#define VEOF 0 /** EOF character */
|
#define VEOF 0 /** EOF character */
|
||||||
#define VEOL 1 /** EOL character */
|
#define VEOL 1 /** EOL character */
|
||||||
#define VERASE 2 /** ERASE character */
|
#define VERASE 2 /** ERASE character */
|
||||||
#define VINTR 3 /** INTR character */
|
#define VINTR 3 /** INTR character */
|
||||||
#define VKILL 4 /** KILL character */
|
#define VKILL 4 /** KILL character */
|
||||||
#define VMIN 5 /** MIN value */
|
#define VMIN 5 /** MIN value */
|
||||||
#define VQUIT 6 /** QUIT character */
|
#define VQUIT 6 /** QUIT character */
|
||||||
#define VSTART 7 /** START character */
|
#define VSTART 7 /** START character */
|
||||||
#define VSTOP 8 /** STOP character */
|
#define VSTOP 8 /** STOP character */
|
||||||
#define VSUSP 9 /** SUSP character */
|
#define VSUSP 9 /** SUSP character */
|
||||||
#define VTIME 10 /** TIME value */
|
#define VTIME 10 /** TIME value */
|
||||||
#define NCCS (VTIME + 1) /** Size of the array c_cc for control characters */
|
#define NCCS (VTIME + 1) /** Size of the array c_cc for control characters */
|
||||||
|
|
||||||
// input modes for use as flags in the c_iflag field
|
// input modes for use as flags in the c_iflag field
|
||||||
#define BRKINT (1u << 0) /** Signal interrupt on break. */
|
#define BRKINT (1u << 0) /** Signal interrupt on break. */
|
||||||
#define ICRNL (1u << 1) /** Map CR to NL on input. */
|
#define ICRNL (1u << 1) /** Map CR to NL on input. */
|
||||||
#define IGNBRK (1u << 2) /** Ignore break condition. */
|
#define IGNBRK (1u << 2) /** Ignore break condition. */
|
||||||
#define IGNCR (1u << 3) /** Ignore CR. */
|
#define IGNCR (1u << 3) /** Ignore CR. */
|
||||||
#define IGNPAR (1u << 4) /** Ignore characters with parity errors. */
|
#define IGNPAR (1u << 4) /** Ignore characters with parity errors. */
|
||||||
#define INLCR (1u << 5) /** Map NL to CR on input. */
|
#define INLCR (1u << 5) /** Map NL to CR on input. */
|
||||||
#define INPCK (1u << 6) /** Enable input parity check. */
|
#define INPCK (1u << 6) /** Enable input parity check. */
|
||||||
#define ISTRIP (1u << 7) /** Strip character. */
|
#define ISTRIP (1u << 7) /** Strip character. */
|
||||||
#define IUCLC (1u << 8) /** Map upper-case to lower-case on input (LEGACY). */
|
#define IUCLC (1u << 8) /** Map upper-case to lower-case on input (LEGACY). */
|
||||||
#define IXANY (1u << 9) /** Enable any character to restart output. */
|
#define IXANY (1u << 9) /** Enable any character to restart output. */
|
||||||
#define IXOFF (1u << 10) /** Enable start/stop input control. */
|
#define IXOFF (1u << 10) /** Enable start/stop input control. */
|
||||||
#define IXON (1u << 11) /** Enable start/stop output control. */
|
#define IXON (1u << 11) /** Enable start/stop output control. */
|
||||||
#define PARMRK (1u << 12) /** Mark parity errors. */
|
#define PARMRK (1u << 12) /** Mark parity errors. */
|
||||||
|
|
||||||
// output Modes for use as flags in the c_oflag field
|
// output Modes for use as flags in the c_oflag field
|
||||||
#define OPOST (1u << 0) /** Post-process output */
|
#define OPOST (1u << 0) /** Post-process output */
|
||||||
#define OLCUC (1u << 1) /** Map lower-case to upper-case on output (LEGACY). */
|
#define OLCUC (1u << 1) /** Map lower-case to upper-case on output (LEGACY). */
|
||||||
#define ONLCR (1u << 2) /** Map NL to CR-NL on output. */
|
#define ONLCR (1u << 2) /** Map NL to CR-NL on output. */
|
||||||
#define OCRNL (1u << 3) /** Map CR to NL on output. */
|
#define OCRNL (1u << 3) /** Map CR to NL on output. */
|
||||||
#define ONOCR (1u << 4) /** No CR output at column 0. */
|
#define ONOCR (1u << 4) /** No CR output at column 0. */
|
||||||
#define ONLRET (1u << 5) /** NL performs CR function. */
|
#define ONLRET (1u << 5) /** NL performs CR function. */
|
||||||
#define OFILL (1u << 6) /** Use fill characters for delay. */
|
#define OFILL (1u << 6) /** Use fill characters for delay. */
|
||||||
#define NLDLY (1u << 7) /** Select newline delays: */
|
#define NLDLY (1u << 7) /** Select newline delays: */
|
||||||
#define NL0 (0u << 7) /** Newline character type 0. */
|
#define NL0 (0u << 7) /** Newline character type 0. */
|
||||||
#define NL1 (1u << 7) /** Newline character type 1. */
|
#define NL1 (1u << 7) /** Newline character type 1. */
|
||||||
#define CRDLY (3u << 8) /** Select carriage-return delays: */
|
#define CRDLY (3u << 8) /** Select carriage-return delays: */
|
||||||
#define CR0 (0u << 8) /** Carriage-return delay type 0. */
|
#define CR0 (0u << 8) /** Carriage-return delay type 0. */
|
||||||
#define CR1 (1u << 8) /** Carriage-return delay type 1. */
|
#define CR1 (1u << 8) /** Carriage-return delay type 1. */
|
||||||
#define CR2 (2u << 8) /** Carriage-return delay type 2. */
|
#define CR2 (2u << 8) /** Carriage-return delay type 2. */
|
||||||
#define CR3 (3u << 8) /** Carriage-return delay type 3. */
|
#define CR3 (3u << 8) /** Carriage-return delay type 3. */
|
||||||
#define TABDLY (3u << 10) /** Select horizontal-tab delays: */
|
#define TABDLY (3u << 10) /** Select horizontal-tab delays: */
|
||||||
#define TAB0 (0u << 10) /** Horizontal-tab delay type 0. */
|
#define TAB0 (0u << 10) /** Horizontal-tab delay type 0. */
|
||||||
#define TAB1 (1u << 10) /** Horizontal-tab delay type 1. */
|
#define TAB1 (1u << 10) /** Horizontal-tab delay type 1. */
|
||||||
#define TAB2 (2u << 10) /** Horizontal-tab delay type 2. */
|
#define TAB2 (2u << 10) /** Horizontal-tab delay type 2. */
|
||||||
#define TAB3 (3u << 10) /** Expand tabs to spaces. */
|
#define TAB3 (3u << 10) /** Expand tabs to spaces. */
|
||||||
#define BSDLY (1u << 12) /** Select backspace delays: */
|
#define BSDLY (1u << 12) /** Select backspace delays: */
|
||||||
#define BS0 (0u << 12) /** Backspace-delay type 0. */
|
#define BS0 (0u << 12) /** Backspace-delay type 0. */
|
||||||
#define BS1 (1u << 12) /** Backspace-delay type 1. */
|
#define BS1 (1u << 12) /** Backspace-delay type 1. */
|
||||||
#define VTDLY (1u << 13) /** Select vertical-tab delays: */
|
#define VTDLY (1u << 13) /** Select vertical-tab delays: */
|
||||||
#define VT0 (0u << 13) /** Vertical-tab delay type 0. */
|
#define VT0 (0u << 13) /** Vertical-tab delay type 0. */
|
||||||
#define VT1 (1u << 13) /** Vertical-tab delay type 1. */
|
#define VT1 (1u << 13) /** Vertical-tab delay type 1. */
|
||||||
#define FFDLY (1u << 14) /** Select form-feed delays: */
|
#define FFDLY (1u << 14) /** Select form-feed delays: */
|
||||||
#define FF0 (0u << 14) /** Form-feed delay type 0. */
|
#define FF0 (0u << 14) /** Form-feed delay type 0. */
|
||||||
#define FF1 (1u << 14) /** Form-feed delay type 1. */
|
#define FF1 (1u << 14) /** Form-feed delay type 1. */
|
||||||
|
|
||||||
// Baud Rate Selection. Valid values for objects of type speed_t:
|
// Baud Rate Selection. Valid values for objects of type speed_t:
|
||||||
// CBAUD range B0 - B38400
|
// CBAUD range B0 - B38400
|
||||||
#define B0 0 /** Hang up */
|
#define B0 0 /** Hang up */
|
||||||
#define B50 1
|
#define B50 1
|
||||||
#define B75 2
|
#define B75 2
|
||||||
#define B110 3
|
#define B110 3
|
||||||
#define B134 4
|
#define B134 4
|
||||||
#define B150 5
|
#define B150 5
|
||||||
#define B200 6
|
#define B200 6
|
||||||
#define B300 7
|
#define B300 7
|
||||||
#define B600 8
|
#define B600 8
|
||||||
#define B1200 9
|
#define B1200 9
|
||||||
#define B1800 10
|
#define B1800 10
|
||||||
#define B2400 11
|
#define B2400 11
|
||||||
#define B4800 12
|
#define B4800 12
|
||||||
#define B9600 13
|
#define B9600 13
|
||||||
#define B19200 14
|
#define B19200 14
|
||||||
#define B38400 15
|
#define B38400 15
|
||||||
// CBAUDEX range B57600 - B4000000
|
// CBAUDEX range B57600 - B4000000
|
||||||
#define B57600 16
|
#define B57600 16
|
||||||
#define B115200 17
|
#define B115200 17
|
||||||
#define B230400 18
|
#define B230400 18
|
||||||
#define B460800 19
|
#define B460800 19
|
||||||
#define B500000 20
|
#define B500000 20
|
||||||
#define B576000 21
|
#define B576000 21
|
||||||
#define B921600 22
|
#define B921600 22
|
||||||
#define B1000000 23
|
#define B1000000 23
|
||||||
#define B1152000 24
|
#define B1152000 24
|
||||||
#define B1500000 25
|
#define B1500000 25
|
||||||
#define B2000000 26
|
#define B2000000 26
|
||||||
#define B2500000 27
|
#define B2500000 27
|
||||||
#define B3000000 28
|
#define B3000000 28
|
||||||
#define B3500000 29
|
#define B3500000 29
|
||||||
#define B4000000 30
|
#define B4000000 30
|
||||||
|
|
||||||
// Control Modes for the c_cflag field:
|
// Control Modes for the c_cflag field:
|
||||||
#define CSIZE (3u << 0) /* Character size: */
|
#define CSIZE (3u << 0) /* Character size: */
|
||||||
#define CS5 (0u << 0) /** 5 bits. */
|
#define CS5 (0u << 0) /** 5 bits. */
|
||||||
#define CS6 (1u << 0) /** 6 bits. */
|
#define CS6 (1u << 0) /** 6 bits. */
|
||||||
#define CS7 (2u << 0) /** 7 bits. */
|
#define CS7 (2u << 0) /** 7 bits. */
|
||||||
#define CS8 (3u << 0) /** 8 bits. */
|
#define CS8 (3u << 0) /** 8 bits. */
|
||||||
#define CSTOPB (1u << 2) /** Send two stop bits, else one. */
|
#define CSTOPB (1u << 2) /** Send two stop bits, else one. */
|
||||||
#define CREAD (1u << 3) /** Enable receiver. */
|
#define CREAD (1u << 3) /** Enable receiver. */
|
||||||
#define PARENB (1u << 4) /** Parity enable. */
|
#define PARENB (1u << 4) /** Parity enable. */
|
||||||
#define PARODD (1u << 5) /** Odd parity, else even. */
|
#define PARODD (1u << 5) /** Odd parity, else even. */
|
||||||
#define HUPCL (1u << 6) /** Hang up on last close. */
|
#define HUPCL (1u << 6) /** Hang up on last close. */
|
||||||
#define CLOCAL (1u << 7) /** Ignore modem status lines. */
|
#define CLOCAL (1u << 7) /** Ignore modem status lines. */
|
||||||
#define CBAUD (1u << 8) /** Use baud rates defined by B0-B38400 macros. */
|
#define CBAUD (1u << 8) /** Use baud rates defined by B0-B38400 macros. */
|
||||||
#define CBAUDEX (1u << 9) /** Use baud rates defined by B57600-B4000000 macros. */
|
#define CBAUDEX (1u << 9) /** Use baud rates defined by B57600-B4000000 macros. */
|
||||||
#define BOTHER (1u << 10) /** Use custom baud rates */
|
#define BOTHER (1u << 10) /** Use custom baud rates */
|
||||||
|
|
||||||
// Local Modes for c_lflag field:
|
// Local Modes for c_lflag field:
|
||||||
#define ECHO (1u << 0) /** Enable echo. */
|
#define ECHO (1u << 0) /** Enable echo. */
|
||||||
#define ECHOE (1u << 1) /** Echo erase character as error-correcting backspace. */
|
#define ECHOE (1u << 1) /** Echo erase character as error-correcting backspace. */
|
||||||
#define ECHOK (1u << 2) /** Echo KILL. */
|
#define ECHOK (1u << 2) /** Echo KILL. */
|
||||||
#define ECHONL (1u << 3) /** Echo NL. */
|
#define ECHONL (1u << 3) /** Echo NL. */
|
||||||
#define ICANON (1u << 4) /** Canonical input (erase and kill processing). */
|
#define ICANON (1u << 4) /** Canonical input (erase and kill processing). */
|
||||||
#define IEXTEN (1u << 5) /** Enable extended input character processing. */
|
#define IEXTEN (1u << 5) /** Enable extended input character processing. */
|
||||||
#define ISIG (1u << 6) /** Enable signals. */
|
#define ISIG (1u << 6) /** Enable signals. */
|
||||||
#define NOFLSH (1u << 7) /** Disable flush after interrupt or quit. */
|
#define NOFLSH (1u << 7) /** Disable flush after interrupt or quit. */
|
||||||
#define TOSTOP (1u << 8) /** Send SIGTTOU for background output. */
|
#define TOSTOP (1u << 8) /** Send SIGTTOU for background output. */
|
||||||
#define XCASE (1u << 9) /** Canonical upper/lower presentation (LEGACY). */
|
#define XCASE (1u << 9) /** Canonical upper/lower presentation (LEGACY). */
|
||||||
|
|
||||||
// Attribute Selection constants for use with tcsetattr():
|
// Attribute Selection constants for use with tcsetattr():
|
||||||
#define TCSANOW 0 /** Change attributes immediately. */
|
#define TCSANOW 0 /** Change attributes immediately. */
|
||||||
#define TCSADRAIN 1 /** Change attributes when output has drained. */
|
#define TCSADRAIN 1 /** Change attributes when output has drained. */
|
||||||
#define TCSAFLUSH 2 /** Change attributes when output has drained; also flush pending input. */
|
#define TCSAFLUSH 2 /** Change attributes when output has drained; also flush pending input. */
|
||||||
|
|
||||||
// Line Control constants for use with tcflush():
|
// Line Control constants for use with tcflush():
|
||||||
#define TCIFLUSH 0 /** Flush pending input. Flush untransmitted output. */
|
#define TCIFLUSH 0 /** Flush pending input. Flush untransmitted output. */
|
||||||
#define TCIOFLUSH 1 /** Flush both pending input and untransmitted output. */
|
#define TCIOFLUSH 1 /** Flush both pending input and untransmitted output. */
|
||||||
#define TCOFLUSH 2 /** Flush untransmitted output. */
|
#define TCOFLUSH 2 /** Flush untransmitted output. */
|
||||||
|
|
||||||
// constants for use with tcflow():
|
// constants for use with tcflow():
|
||||||
#define TCIOFF 0 /** Transmit a STOP character, intended to suspend input data. */
|
#define TCIOFF 0 /** Transmit a STOP character, intended to suspend input data. */
|
||||||
#define TCION 1 /** Transmit a START character, intended to restart input data. */
|
#define TCION 1 /** Transmit a START character, intended to restart input data. */
|
||||||
#define TCOOFF 2 /** Suspend output. */
|
#define TCOOFF 2 /** Suspend output. */
|
||||||
#define TCOON 3 /** Restart output. */
|
#define TCOON 3 /** Restart output. */
|
||||||
|
|
||||||
typedef uint8_t cc_t;
|
typedef uint8_t cc_t;
|
||||||
typedef uint32_t speed_t;
|
typedef uint32_t speed_t;
|
||||||
typedef uint16_t tcflag_t;
|
typedef uint16_t tcflag_t;
|
||||||
|
|
||||||
struct termios {
|
struct termios {
|
||||||
tcflag_t c_iflag; /** Input modes */
|
tcflag_t c_iflag; /** Input modes */
|
||||||
tcflag_t c_oflag; /** Output modes */
|
tcflag_t c_oflag; /** Output modes */
|
||||||
tcflag_t c_cflag; /** Control modes */
|
tcflag_t c_cflag; /** Control modes */
|
||||||
tcflag_t c_lflag; /** Local modes */
|
tcflag_t c_lflag; /** Local modes */
|
||||||
cc_t c_cc[NCCS]; /** Control characters */
|
cc_t c_cc[NCCS]; /** Control characters */
|
||||||
speed_t c_ispeed; /** input baud rate */
|
speed_t c_ispeed; /** input baud rate */
|
||||||
speed_t c_ospeed; /** output baud rate */
|
speed_t c_ospeed; /** output baud rate */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extracts the input baud rate from the input structure exactly (without interpretation).
|
* @brief Extracts the input baud rate from the input structure exactly (without interpretation).
|
||||||
*
|
*
|
||||||
* @param p input termios structure
|
* @param p input termios structure
|
||||||
* @return input baud rate
|
* @return input baud rate
|
||||||
*/
|
*/
|
||||||
speed_t cfgetispeed(const struct termios *p);
|
speed_t cfgetispeed(const struct termios *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extracts the output baud rate from the input structure exactly (without interpretation).
|
* @brief Extracts the output baud rate from the input structure exactly (without interpretation).
|
||||||
*
|
*
|
||||||
* @param p input termios structure
|
* @param p input termios structure
|
||||||
* @return output baud rate
|
* @return output baud rate
|
||||||
*/
|
*/
|
||||||
speed_t cfgetospeed(const struct termios *p);
|
speed_t cfgetospeed(const struct termios *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set input baud rate in the termios structure
|
* @brief Set input baud rate in the termios structure
|
||||||
*
|
*
|
||||||
* There is no effect in hardware until a subsequent call of tcsetattr().
|
* There is no effect in hardware until a subsequent call of tcsetattr().
|
||||||
*
|
*
|
||||||
* @param p input termios structure
|
* @param p input termios structure
|
||||||
* @param sp input baud rate
|
* @param sp input baud rate
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int cfsetispeed(struct termios *p, speed_t sp);
|
int cfsetispeed(struct termios *p, speed_t sp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set output baud rate in the termios structure
|
* @brief Set output baud rate in the termios structure
|
||||||
*
|
*
|
||||||
* There is no effect in hardware until a subsequent call of tcsetattr().
|
* There is no effect in hardware until a subsequent call of tcsetattr().
|
||||||
*
|
*
|
||||||
* @param p input termios structure
|
* @param p input termios structure
|
||||||
* @param sp output baud rate
|
* @param sp output baud rate
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int cfsetospeed(struct termios *p, speed_t sp);
|
int cfsetospeed(struct termios *p, speed_t sp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait for transmission of output
|
* @brief Wait for transmission of output
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int tcdrain(int fd);
|
int tcdrain(int fd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Suspend or restart the transmission or reception of data
|
* @brief Suspend or restart the transmission or reception of data
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @param action selects actions to do
|
* @param action selects actions to do
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int tcflow(int fd, int action);
|
int tcflow(int fd, int action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Flush non-transmitted output data and non-read input data
|
* @brief Flush non-transmitted output data and non-read input data
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @param select selects what should be flushed
|
* @param select selects what should be flushed
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int tcflush(int fd, int select);
|
int tcflush(int fd, int select);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the parameters of the terminal
|
* @brief Gets the parameters of the terminal
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @param p output termios structure
|
* @param p output termios structure
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int tcgetattr(int fd, struct termios *p);
|
int tcgetattr(int fd, struct termios *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get process group ID for session leader for controlling terminal
|
* @brief Get process group ID for session leader for controlling terminal
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @return process group ID when successful, -1 otherwise with errno set
|
* @return process group ID when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
pid_t tcgetsid(int fd);
|
pid_t tcgetsid(int fd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send a break for a specific duration
|
* @brief Send a break for a specific duration
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @param duration duration of break
|
* @param duration duration of break
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int tcsendbreak(int fd, int duration);
|
int tcsendbreak(int fd, int duration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the parameters of the terminal
|
* @brief Sets the parameters of the terminal
|
||||||
*
|
*
|
||||||
* @param fd file descriptor of the terminal
|
* @param fd file descriptor of the terminal
|
||||||
* @param optional_actions optional actions
|
* @param optional_actions optional actions
|
||||||
* @param p input termios structure
|
* @param p input termios structure
|
||||||
* @return 0 when successful, -1 otherwise with errno set
|
* @return 0 when successful, -1 otherwise with errno set
|
||||||
*/
|
*/
|
||||||
int tcsetattr(int fd, int optional_actions, const struct termios *p);
|
int tcsetattr(int fd, int optional_actions, const struct termios *p);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
|
|
||||||
#endif //__ESP_SYS_TERMIOS_H__
|
#endif //__ESP_SYS_TERMIOS_H__
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
/* Newlib sys/time.h defines timerisset, timerclear, timercmp, timeradd, timersub macros
|
/* Newlib sys/time.h defines timerisset, timerclear, timercmp, timeradd, timersub macros
|
||||||
for __CYGWIN__ and __rtems__. We want to define these macros in IDF as well.
|
for __CYGWIN__ and __rtems__. We want to define these macros in IDF as well.
|
||||||
Since we wish to use un-modified newlib headers until a patched newlib version is
|
Since we wish to use un-modified newlib headers until a patched newlib version is
|
||||||
available, temporarily define __rtems__ here before including sys/time.h.
|
available, temporarily define __rtems__ here before including sys/time.h.
|
||||||
__rtems__ is chosen instead of __CYGWIN__ since there are no other checks in sys/time.h
|
__rtems__ is chosen instead of __CYGWIN__ since there are no other checks in sys/time.h
|
||||||
which depend on __rtems__.
|
which depend on __rtems__.
|
||||||
|
|
||||||
Also, so that __rtems__ define does not affect other headers included from sys/time.h,
|
Also, so that __rtems__ define does not affect other headers included from sys/time.h,
|
||||||
we include them here in advance (_ansi.h and sys/types.h).
|
we include them here in advance (_ansi.h and sys/types.h).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <_ansi.h>
|
#include <_ansi.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#define __rtems__
|
#define __rtems__
|
||||||
#include_next <sys/time.h>
|
#include_next <sys/time.h>
|
||||||
#undef __rtems__
|
#undef __rtems__
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct iovec;
|
struct iovec;
|
||||||
|
|
||||||
int writev(int s, const struct iovec *iov, int iovcnt);
|
int writev(int s, const struct iovec *iov, int iovcnt);
|
||||||
|
|
||||||
ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
|
ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AF_UNIX 1 /* local to host (pipes) */
|
#define AF_UNIX 1 /* local to host (pipes) */
|
||||||
|
|
||||||
struct sockaddr_un {
|
struct sockaddr_un {
|
||||||
short sun_family; /*AF_UNIX*/
|
short sun_family; /*AF_UNIX*/
|
||||||
char sun_path[108]; /*path name */
|
char sun_path[108]; /*path name */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include_next <sys/unistd.h>
|
#include_next <sys/unistd.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int truncate(const char *, off_t __length);
|
int truncate(const char *, off_t __length);
|
||||||
int gethostname(char *__name, size_t __len);
|
int gethostname(char *__name, size_t __len);
|
||||||
int getentropy(void *buffer, size_t length);
|
int getentropy(void *buffer, size_t length);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UTIME_H_
|
#ifndef _UTIME_H_
|
||||||
#define _UTIME_H_
|
#define _UTIME_H_
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct utimbuf {
|
struct utimbuf {
|
||||||
time_t actime; // access time
|
time_t actime; // access time
|
||||||
time_t modtime; // modification time
|
time_t modtime; // modification time
|
||||||
};
|
};
|
||||||
|
|
||||||
int utime(const char *path, const struct utimbuf *times);
|
int utime(const char *path, const struct utimbuf *times);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _UTIME_H_ */
|
#endif /* _UTIME_H_ */
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include_next <time.h>
|
#include_next <time.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _POSIX_TIMERS 1
|
#define _POSIX_TIMERS 1
|
||||||
#ifndef CLOCK_MONOTONIC
|
#ifndef CLOCK_MONOTONIC
|
||||||
#define CLOCK_MONOTONIC (clockid_t)4
|
#define CLOCK_MONOTONIC (clockid_t)4
|
||||||
#endif
|
#endif
|
||||||
#ifndef CLOCK_BOOTTIME
|
#ifndef CLOCK_BOOTTIME
|
||||||
#define CLOCK_BOOTTIME (clockid_t)4
|
#define CLOCK_BOOTTIME (clockid_t)4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int clock_settime(clockid_t clock_id, const struct timespec *tp);
|
int clock_settime(clockid_t clock_id, const struct timespec *tp);
|
||||||
int clock_gettime(clockid_t clock_id, struct timespec *tp);
|
int clock_gettime(clockid_t clock_id, struct timespec *tp);
|
||||||
int clock_getres(clockid_t clock_id, struct timespec *res);
|
int clock_getres(clockid_t clock_id, struct timespec *res);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+87
-87
@@ -1,87 +1,87 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
||||||
{
|
{
|
||||||
struct timeval tv = {
|
struct timeval tv = {
|
||||||
// timeout is in milliseconds
|
// timeout is in milliseconds
|
||||||
.tv_sec = timeout / 1000,
|
.tv_sec = timeout / 1000,
|
||||||
.tv_usec = (timeout % 1000) * 1000,
|
.tv_usec = (timeout % 1000) * 1000,
|
||||||
};
|
};
|
||||||
int max_fd = -1;
|
int max_fd = -1;
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
fd_set writefds;
|
fd_set writefds;
|
||||||
fd_set errorfds;
|
fd_set errorfds;
|
||||||
struct _reent* r = __getreent();
|
struct _reent* r = __getreent();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (fds == NULL) {
|
if (fds == NULL) {
|
||||||
__errno_r(r) = ENOENT;
|
__errno_r(r) = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_ZERO(&writefds);
|
FD_ZERO(&writefds);
|
||||||
FD_ZERO(&errorfds);
|
FD_ZERO(&errorfds);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nfds; ++i) {
|
for (unsigned int i = 0; i < nfds; ++i) {
|
||||||
fds[i].revents = 0;
|
fds[i].revents = 0;
|
||||||
|
|
||||||
if (fds[i].fd < 0) {
|
if (fds[i].fd < 0) {
|
||||||
// revents should remain 0 and events ignored (according to the documentation of poll()).
|
// revents should remain 0 and events ignored (according to the documentation of poll()).
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fds[i].fd >= FD_SETSIZE) {
|
if (fds[i].fd >= FD_SETSIZE) {
|
||||||
fds[i].revents |= POLLNVAL;
|
fds[i].revents |= POLLNVAL;
|
||||||
++ret;
|
++ret;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fds[i].events & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) {
|
if (fds[i].events & (POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI)) {
|
||||||
FD_SET(fds[i].fd, &readfds);
|
FD_SET(fds[i].fd, &readfds);
|
||||||
FD_SET(fds[i].fd, &errorfds);
|
FD_SET(fds[i].fd, &errorfds);
|
||||||
max_fd = MAX(max_fd, fds[i].fd);
|
max_fd = MAX(max_fd, fds[i].fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fds[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND)) {
|
if (fds[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND)) {
|
||||||
FD_SET(fds[i].fd, &writefds);
|
FD_SET(fds[i].fd, &writefds);
|
||||||
FD_SET(fds[i].fd, &errorfds);
|
FD_SET(fds[i].fd, &errorfds);
|
||||||
max_fd = MAX(max_fd, fds[i].fd);
|
max_fd = MAX(max_fd, fds[i].fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int select_ret = select(max_fd + 1, &readfds, &writefds, &errorfds, timeout < 0 ? NULL : &tv);
|
const int select_ret = select(max_fd + 1, &readfds, &writefds, &errorfds, timeout < 0 ? NULL : &tv);
|
||||||
|
|
||||||
if (select_ret > 0) {
|
if (select_ret > 0) {
|
||||||
ret += select_ret;
|
ret += select_ret;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nfds; ++i) {
|
for (unsigned int i = 0; i < nfds; ++i) {
|
||||||
if (FD_ISSET(fds[i].fd, &readfds)) {
|
if (FD_ISSET(fds[i].fd, &readfds)) {
|
||||||
fds[i].revents |= POLLIN;
|
fds[i].revents |= POLLIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(fds[i].fd, &writefds)) {
|
if (FD_ISSET(fds[i].fd, &writefds)) {
|
||||||
fds[i].revents |= POLLOUT;
|
fds[i].revents |= POLLOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(fds[i].fd, &errorfds)) {
|
if (FD_ISSET(fds[i].fd, &errorfds)) {
|
||||||
fds[i].revents |= POLLERR;
|
fds[i].revents |= POLLERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = select_ret;
|
ret = select_ret;
|
||||||
// keeping the errno from select()
|
// keeping the errno from select()
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
target_sources(${COMPONENT_LIB} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/esp_time_impl.c")
|
target_sources(${COMPONENT_LIB} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/esp_time_impl.c")
|
||||||
|
|||||||
+145
-145
@@ -1,145 +1,145 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
|
|
||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
|
|
||||||
#include "esp_private/system_internal.h"
|
#include "esp_private/system_internal.h"
|
||||||
#include "esp_private/esp_clk.h"
|
#include "esp_private/esp_clk.h"
|
||||||
|
|
||||||
#include "esp_time_impl.h"
|
#include "esp_time_impl.h"
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
#include "esp32/rom/rtc.h"
|
#include "esp32/rom/rtc.h"
|
||||||
#include "esp32/rtc.h"
|
#include "esp32/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
#include "esp32s2/rom/rtc.h"
|
#include "esp32s2/rom/rtc.h"
|
||||||
#include "esp32s2/rtc.h"
|
#include "esp32s2/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
#include "esp32s3/rom/rtc.h"
|
#include "esp32s3/rom/rtc.h"
|
||||||
#include "esp32s3/rtc.h"
|
#include "esp32s3/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||||
#include "esp32c3/rom/rtc.h"
|
#include "esp32c3/rom/rtc.h"
|
||||||
#include "esp32c3/rtc.h"
|
#include "esp32c3/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||||
#include "esp32c2/rom/rtc.h"
|
#include "esp32c2/rom/rtc.h"
|
||||||
#include "esp32c2/rtc.h"
|
#include "esp32c2/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C6
|
#elif CONFIG_IDF_TARGET_ESP32C6
|
||||||
#include "esp32c6/rom/rtc.h"
|
#include "esp32c6/rom/rtc.h"
|
||||||
#include "esp32c6/rtc.h"
|
#include "esp32c6/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C61 //TODO: IDF-9526, refactor this
|
#elif CONFIG_IDF_TARGET_ESP32C61 //TODO: IDF-9526, refactor this
|
||||||
#include "esp32c61/rom/rtc.h"
|
#include "esp32c61/rom/rtc.h"
|
||||||
#include "esp32c61/rtc.h"
|
#include "esp32c61/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
#elif CONFIG_IDF_TARGET_ESP32C5
|
||||||
#include "esp32c5/rom/rtc.h"
|
#include "esp32c5/rom/rtc.h"
|
||||||
#include "esp32c5/rtc.h"
|
#include "esp32c5/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||||
#include "esp32h2/rom/rtc.h"
|
#include "esp32h2/rom/rtc.h"
|
||||||
#include "esp32h2/rtc.h"
|
#include "esp32h2/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/rtc.h"
|
#include "esp32p4/rom/rtc.h"
|
||||||
#include "esp32p4/rtc.h"
|
#include "esp32p4/rtc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Offset between High resolution timer and the RTC.
|
// Offset between High resolution timer and the RTC.
|
||||||
// Initialized after reset or light sleep.
|
// Initialized after reset or light sleep.
|
||||||
#if defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER) && defined(CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER)
|
#if defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER) && defined(CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER)
|
||||||
int64_t s_microseconds_offset = 0;
|
int64_t s_microseconds_offset = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
#ifndef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
static uint64_t s_boot_time; // when RTC is used to persist time, two RTC_STORE registers are used to store boot time instead
|
static uint64_t s_boot_time; // when RTC is used to persist time, two RTC_STORE registers are used to store boot time instead
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static _lock_t s_boot_time_lock;
|
static _lock_t s_boot_time_lock;
|
||||||
|
|
||||||
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) || defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) || defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
||||||
uint64_t esp_time_impl_get_time_since_boot(void)
|
uint64_t esp_time_impl_get_time_since_boot(void)
|
||||||
{
|
{
|
||||||
uint64_t microseconds = 0;
|
uint64_t microseconds = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER
|
#ifdef CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER
|
||||||
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
microseconds = s_microseconds_offset + esp_system_get_time();
|
microseconds = s_microseconds_offset + esp_system_get_time();
|
||||||
#else
|
#else
|
||||||
microseconds = esp_system_get_time();
|
microseconds = esp_system_get_time();
|
||||||
#endif // CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
#endif // CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
#elif defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER)
|
#elif defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER)
|
||||||
microseconds = esp_rtc_get_time_us();
|
microseconds = esp_rtc_get_time_us();
|
||||||
#endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER
|
#endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER
|
||||||
return microseconds;
|
return microseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t esp_time_impl_get_time(void)
|
uint64_t esp_time_impl_get_time(void)
|
||||||
{
|
{
|
||||||
uint64_t microseconds = 0;
|
uint64_t microseconds = 0;
|
||||||
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER )
|
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER )
|
||||||
microseconds = esp_system_get_time();
|
microseconds = esp_system_get_time();
|
||||||
#elif defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
#elif defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
||||||
microseconds = esp_rtc_get_time_us();
|
microseconds = esp_rtc_get_time_us();
|
||||||
#endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER
|
#endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER
|
||||||
return microseconds;
|
return microseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) || defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
#endif // defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) || defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
||||||
|
|
||||||
void esp_time_impl_set_boot_time(uint64_t time_us)
|
void esp_time_impl_set_boot_time(uint64_t time_us)
|
||||||
{
|
{
|
||||||
_lock_acquire(&s_boot_time_lock);
|
_lock_acquire(&s_boot_time_lock);
|
||||||
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
REG_WRITE(RTC_BOOT_TIME_LOW_REG, (uint32_t)(time_us & 0xffffffff));
|
REG_WRITE(RTC_BOOT_TIME_LOW_REG, (uint32_t)(time_us & 0xffffffff));
|
||||||
REG_WRITE(RTC_BOOT_TIME_HIGH_REG, (uint32_t)(time_us >> 32));
|
REG_WRITE(RTC_BOOT_TIME_HIGH_REG, (uint32_t)(time_us >> 32));
|
||||||
#else
|
#else
|
||||||
s_boot_time = time_us;
|
s_boot_time = time_us;
|
||||||
#endif
|
#endif
|
||||||
_lock_release(&s_boot_time_lock);
|
_lock_release(&s_boot_time_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t esp_time_impl_get_boot_time(void)
|
uint64_t esp_time_impl_get_boot_time(void)
|
||||||
{
|
{
|
||||||
uint64_t result;
|
uint64_t result;
|
||||||
_lock_acquire(&s_boot_time_lock);
|
_lock_acquire(&s_boot_time_lock);
|
||||||
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
result = ((uint64_t) REG_READ(RTC_BOOT_TIME_LOW_REG)) + (((uint64_t) REG_READ(RTC_BOOT_TIME_HIGH_REG)) << 32);
|
result = ((uint64_t) REG_READ(RTC_BOOT_TIME_LOW_REG)) + (((uint64_t) REG_READ(RTC_BOOT_TIME_HIGH_REG)) << 32);
|
||||||
#else
|
#else
|
||||||
result = s_boot_time;
|
result = s_boot_time;
|
||||||
#endif
|
#endif
|
||||||
_lock_release(&s_boot_time_lock);
|
_lock_release(&s_boot_time_lock);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_set_time_from_rtc(void)
|
void esp_set_time_from_rtc(void)
|
||||||
{
|
{
|
||||||
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) && defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) && defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
||||||
// initialize time from RTC clock
|
// initialize time from RTC clock
|
||||||
s_microseconds_offset = esp_rtc_get_time_us() - esp_system_get_time();
|
s_microseconds_offset = esp_rtc_get_time_us() - esp_system_get_time();
|
||||||
#endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER && CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
#endif // CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER && CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_sync_timekeeping_timers(void)
|
void esp_sync_timekeeping_timers(void)
|
||||||
{
|
{
|
||||||
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) && defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
#if defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) && defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
settimeofday(&tv, NULL);
|
settimeofday(&tv, NULL);
|
||||||
int64_t s_microseconds_offset_cur = esp_rtc_get_time_us() - esp_system_get_time();
|
int64_t s_microseconds_offset_cur = esp_rtc_get_time_us() - esp_system_get_time();
|
||||||
esp_time_impl_set_boot_time(esp_time_impl_get_boot_time() + ((int64_t)s_microseconds_offset - s_microseconds_offset_cur));
|
esp_time_impl_set_boot_time(esp_time_impl_get_boot_time() + ((int64_t)s_microseconds_offset - s_microseconds_offset_cur));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_time_impl_init(void)
|
void esp_time_impl_init(void)
|
||||||
{
|
{
|
||||||
esp_set_time_from_rtc();
|
esp_set_time_from_rtc();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +1,79 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "esp_stdatomic.h"
|
#include "esp_stdatomic.h"
|
||||||
|
|
||||||
#undef SYNC_OP_FUNCTIONS
|
#undef SYNC_OP_FUNCTIONS
|
||||||
#undef _ATOMIC_OP_FUNCTION
|
#undef _ATOMIC_OP_FUNCTION
|
||||||
#undef ATOMIC_LOAD
|
#undef ATOMIC_LOAD
|
||||||
#undef ATOMIC_CMP_EXCHANGE
|
#undef ATOMIC_CMP_EXCHANGE
|
||||||
#undef ATOMIC_STORE
|
#undef ATOMIC_STORE
|
||||||
#undef ATOMIC_EXCHANGE
|
#undef ATOMIC_EXCHANGE
|
||||||
#undef SYNC_BOOL_CMP_EXCHANGE
|
#undef SYNC_BOOL_CMP_EXCHANGE
|
||||||
#undef SYNC_VAL_CMP_EXCHANGE
|
#undef SYNC_VAL_CMP_EXCHANGE
|
||||||
#undef SYNC_LOCK_TEST_AND_SET
|
#undef SYNC_LOCK_TEST_AND_SET
|
||||||
#undef SYNC_LOCK_RELEASE
|
#undef SYNC_LOCK_RELEASE
|
||||||
|
|
||||||
#define SYNC_OP_FUNCTIONS(n, type, name)
|
#define SYNC_OP_FUNCTIONS(n, type, name)
|
||||||
|
|
||||||
#define _ATOMIC_OP_FUNCTION(n, type, name_1, name_2, ret_var, operation, inverse) \
|
#define _ATOMIC_OP_FUNCTION(n, type, name_1, name_2, ret_var, operation, inverse) \
|
||||||
type __atomic_s32c1i_ ##name_1 ##_ ##name_2 ##_ ##n (volatile void* ptr, type value, int memorder) \
|
type __atomic_s32c1i_ ##name_1 ##_ ##name_2 ##_ ##n (volatile void* ptr, type value, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
return __atomic_ ##name_1 ##_ ##name_2 ##_ ##n (ptr, value, memorder); \
|
return __atomic_ ##name_1 ##_ ##name_2 ##_ ##n (ptr, value, memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_LOAD(n, type) \
|
#define ATOMIC_LOAD(n, type) \
|
||||||
type __atomic_s32c1i_load_ ## n (const volatile void* ptr, int memorder) \
|
type __atomic_s32c1i_load_ ## n (const volatile void* ptr, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
return __atomic_load_ ## n (ptr, memorder); \
|
return __atomic_load_ ## n (ptr, memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_CMP_EXCHANGE(n, type) \
|
#define ATOMIC_CMP_EXCHANGE(n, type) \
|
||||||
bool __atomic_s32c1i_compare_exchange_ ## n (volatile void* ptr, void* expected, type desired, bool weak, int success, int failure) \
|
bool __atomic_s32c1i_compare_exchange_ ## n (volatile void* ptr, void* expected, type desired, bool weak, int success, int failure) \
|
||||||
{ \
|
{ \
|
||||||
return __atomic_compare_exchange_ ## n (ptr, expected, desired, weak, success, failure); \
|
return __atomic_compare_exchange_ ## n (ptr, expected, desired, weak, success, failure); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_STORE(n, type) \
|
#define ATOMIC_STORE(n, type) \
|
||||||
void __atomic_s32c1i_store_ ## n (volatile void * ptr, type value, int memorder) \
|
void __atomic_s32c1i_store_ ## n (volatile void * ptr, type value, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
__atomic_store_ ## n (ptr, value, memorder); \
|
__atomic_store_ ## n (ptr, value, memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_EXCHANGE(n, type) \
|
#define ATOMIC_EXCHANGE(n, type) \
|
||||||
type __atomic_s32c1i_exchange_ ## n (volatile void* ptr, type value, int memorder) \
|
type __atomic_s32c1i_exchange_ ## n (volatile void* ptr, type value, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
return __atomic_exchange_ ## n (ptr, value, memorder); \
|
return __atomic_exchange_ ## n (ptr, value, memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
#define SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
||||||
bool __sync_s32c1i_bool_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired) \
|
bool __sync_s32c1i_bool_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired) \
|
||||||
{ \
|
{ \
|
||||||
return __sync_bool_compare_and_swap_ ## n (ptr, expected, desired); \
|
return __sync_bool_compare_and_swap_ ## n (ptr, expected, desired); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYNC_VAL_CMP_EXCHANGE(n, type) \
|
#define SYNC_VAL_CMP_EXCHANGE(n, type) \
|
||||||
type __sync_s32c1i_val_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired) \
|
type __sync_s32c1i_val_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired) \
|
||||||
{ \
|
{ \
|
||||||
return __sync_val_compare_and_swap_ ## n (ptr, expected, desired); \
|
return __sync_val_compare_and_swap_ ## n (ptr, expected, desired); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYNC_LOCK_TEST_AND_SET(n, type) \
|
#define SYNC_LOCK_TEST_AND_SET(n, type) \
|
||||||
type __sync_s32c1i_lock_test_and_set_ ## n (volatile void* ptr, type value) \
|
type __sync_s32c1i_lock_test_and_set_ ## n (volatile void* ptr, type value) \
|
||||||
{ \
|
{ \
|
||||||
return __sync_lock_test_and_set_ ## n (ptr, value); \
|
return __sync_lock_test_and_set_ ## n (ptr, value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYNC_LOCK_RELEASE(n, type) \
|
#define SYNC_LOCK_RELEASE(n, type) \
|
||||||
void __sync_s32c1i_lock_release_ ## n (volatile void* ptr) \
|
void __sync_s32c1i_lock_release_ ## n (volatile void* ptr) \
|
||||||
{ \
|
{ \
|
||||||
__sync_lock_release_ ## n (ptr); \
|
__sync_lock_release_ ## n (ptr); \
|
||||||
}
|
}
|
||||||
|
|
||||||
ATOMIC_FUNCTIONS(1, unsigned char)
|
ATOMIC_FUNCTIONS(1, unsigned char)
|
||||||
ATOMIC_FUNCTIONS(2, short unsigned int)
|
ATOMIC_FUNCTIONS(2, short unsigned int)
|
||||||
ATOMIC_FUNCTIONS(4, unsigned int)
|
ATOMIC_FUNCTIONS(4, unsigned int)
|
||||||
|
|||||||
@@ -1,296 +1,296 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#ifdef __XTENSA__
|
#ifdef __XTENSA__
|
||||||
#include "xtensa/config/core-isa.h"
|
#include "xtensa/config/core-isa.h"
|
||||||
|
|
||||||
#ifndef XCHAL_HAVE_S32C1I
|
#ifndef XCHAL_HAVE_S32C1I
|
||||||
#error "XCHAL_HAVE_S32C1I not defined, include correct header!"
|
#error "XCHAL_HAVE_S32C1I not defined, include correct header!"
|
||||||
#endif // XCHAL_HAVE_S32C1I
|
#endif // XCHAL_HAVE_S32C1I
|
||||||
|
|
||||||
#ifndef CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#ifndef CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
#define CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND 0
|
#define CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAS_ATOMICS_32 ((XCHAL_HAVE_S32C1I == 1) && !CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
#define HAS_ATOMICS_32 ((XCHAL_HAVE_S32C1I == 1) && !CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
||||||
|
|
||||||
// no 64-bit atomics on Xtensa
|
// no 64-bit atomics on Xtensa
|
||||||
#define HAS_ATOMICS_64 0
|
#define HAS_ATOMICS_64 0
|
||||||
#else // RISCV
|
#else // RISCV
|
||||||
// GCC toolchain will define this pre-processor if "A" extension is supported
|
// GCC toolchain will define this pre-processor if "A" extension is supported
|
||||||
#ifndef __riscv_atomic
|
#ifndef __riscv_atomic
|
||||||
#define __riscv_atomic 0
|
#define __riscv_atomic 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HAS_ATOMICS_32 (__riscv_atomic == 1)
|
#define HAS_ATOMICS_32 (__riscv_atomic == 1)
|
||||||
#define HAS_ATOMICS_64 ((__riscv_atomic == 1) && (__riscv_xlen == 64))
|
#define HAS_ATOMICS_64 ((__riscv_atomic == 1) && (__riscv_xlen == 64))
|
||||||
#endif // (__XTENSA__, __riscv)
|
#endif // (__XTENSA__, __riscv)
|
||||||
|
|
||||||
#if SOC_CPU_CORES_NUM == 1
|
#if SOC_CPU_CORES_NUM == 1
|
||||||
// Single core SoC: atomics can be implemented using portSET_INTERRUPT_MASK_FROM_ISR
|
// Single core SoC: atomics can be implemented using portSET_INTERRUPT_MASK_FROM_ISR
|
||||||
// and portCLEAR_INTERRUPT_MASK_FROM_ISR, which disables and enables interrupts.
|
// and portCLEAR_INTERRUPT_MASK_FROM_ISR, which disables and enables interrupts.
|
||||||
#if CONFIG_FREERTOS_SMP
|
#if CONFIG_FREERTOS_SMP
|
||||||
#define _ATOMIC_ENTER_CRITICAL() unsigned int state = portDISABLE_INTERRUPTS();
|
#define _ATOMIC_ENTER_CRITICAL() unsigned int state = portDISABLE_INTERRUPTS();
|
||||||
#define _ATOMIC_EXIT_CRITICAL() portRESTORE_INTERRUPTS(state)
|
#define _ATOMIC_EXIT_CRITICAL() portRESTORE_INTERRUPTS(state)
|
||||||
#else // CONFIG_FREERTOS_SMP
|
#else // CONFIG_FREERTOS_SMP
|
||||||
#define _ATOMIC_ENTER_CRITICAL() unsigned int state = portSET_INTERRUPT_MASK_FROM_ISR()
|
#define _ATOMIC_ENTER_CRITICAL() unsigned int state = portSET_INTERRUPT_MASK_FROM_ISR()
|
||||||
#define _ATOMIC_EXIT_CRITICAL() portCLEAR_INTERRUPT_MASK_FROM_ISR(state)
|
#define _ATOMIC_EXIT_CRITICAL() portCLEAR_INTERRUPT_MASK_FROM_ISR(state)
|
||||||
#endif // CONFIG_FREERTOS_SMP
|
#endif // CONFIG_FREERTOS_SMP
|
||||||
#else // SOC_CPU_CORES_NUM
|
#else // SOC_CPU_CORES_NUM
|
||||||
|
|
||||||
#define _ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL_SAFE(&s_atomic_lock);
|
#define _ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL_SAFE(&s_atomic_lock);
|
||||||
#define _ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL_SAFE(&s_atomic_lock);
|
#define _ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL_SAFE(&s_atomic_lock);
|
||||||
|
|
||||||
#endif // SOC_CPU_CORES_NUM
|
#endif // SOC_CPU_CORES_NUM
|
||||||
|
|
||||||
#if CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#if CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
|
|
||||||
#define _ATOMIC_IF_NOT_EXT_RAM() \
|
#define _ATOMIC_IF_NOT_EXT_RAM() \
|
||||||
if (!((uintptr_t)ptr >= SOC_EXTRAM_DATA_LOW && (uintptr_t) ptr < SOC_EXTRAM_DATA_HIGH))
|
if (!((uintptr_t)ptr >= SOC_EXTRAM_DATA_LOW && (uintptr_t) ptr < SOC_EXTRAM_DATA_HIGH))
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2) \
|
#define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
type __atomic_s32c1i_ ##name_1 ##_ ##name_2 ##_ ##n (volatile void* ptr, type value, int memorder); \
|
type __atomic_s32c1i_ ##name_1 ##_ ##name_2 ##_ ##n (volatile void* ptr, type value, int memorder); \
|
||||||
return __atomic_s32c1i_ ##name_1 ##_ ##name_2 ##_ ##n (ptr, value, memorder); \
|
return __atomic_s32c1i_ ##name_1 ##_ ##name_2 ##_ ##n (ptr, value, memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_EXCHANGE(n, type) \
|
#define _ATOMIC_HW_STUB_EXCHANGE(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
type __atomic_s32c1i_exchange_ ## n (volatile void* ptr, type value, int memorder); \
|
type __atomic_s32c1i_exchange_ ## n (volatile void* ptr, type value, int memorder); \
|
||||||
return __atomic_s32c1i_exchange_ ## n (ptr, value, memorder); \
|
return __atomic_s32c1i_exchange_ ## n (ptr, value, memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_STORE(n, type) \
|
#define _ATOMIC_HW_STUB_STORE(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
void __atomic_s32c1i_store_ ## n (volatile void * ptr, type value, int memorder); \
|
void __atomic_s32c1i_store_ ## n (volatile void * ptr, type value, int memorder); \
|
||||||
__atomic_s32c1i_store_ ## n (ptr, value, memorder); \
|
__atomic_s32c1i_store_ ## n (ptr, value, memorder); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type) \
|
#define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
bool __atomic_s32c1i_compare_exchange_ ## n (volatile void* ptr, void* expected, type desired, bool weak, int success, int failure); \
|
bool __atomic_s32c1i_compare_exchange_ ## n (volatile void* ptr, void* expected, type desired, bool weak, int success, int failure); \
|
||||||
return __atomic_s32c1i_compare_exchange_ ## n (ptr, expected, desired, weak, success, failure); \
|
return __atomic_s32c1i_compare_exchange_ ## n (ptr, expected, desired, weak, success, failure); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_LOAD(n, type) \
|
#define _ATOMIC_HW_STUB_LOAD(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
type __atomic_s32c1i_load_ ## n (const volatile void* ptr, int memorder); \
|
type __atomic_s32c1i_load_ ## n (const volatile void* ptr, int memorder); \
|
||||||
return __atomic_s32c1i_load_ ## n (ptr,memorder); \
|
return __atomic_s32c1i_load_ ## n (ptr,memorder); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
bool __sync_s32c1i_bool_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired); \
|
bool __sync_s32c1i_bool_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired); \
|
||||||
return __sync_s32c1i_bool_compare_and_swap_ ## n (ptr, expected, desired); \
|
return __sync_s32c1i_bool_compare_and_swap_ ## n (ptr, expected, desired); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type) \
|
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
type __sync_s32c1i_val_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired); \
|
type __sync_s32c1i_val_compare_and_swap_ ## n (volatile void* ptr, type expected, type desired); \
|
||||||
return __sync_s32c1i_val_compare_and_swap_ ## n (ptr, expected, desired); \
|
return __sync_s32c1i_val_compare_and_swap_ ## n (ptr, expected, desired); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type) \
|
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
type __sync_s32c1i_lock_test_and_set_ ## n (volatile void* ptr, type value); \
|
type __sync_s32c1i_lock_test_and_set_ ## n (volatile void* ptr, type value); \
|
||||||
return __sync_s32c1i_lock_test_and_set_ ## n (ptr, value); \
|
return __sync_s32c1i_lock_test_and_set_ ## n (ptr, value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type) \
|
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type) \
|
||||||
_ATOMIC_IF_NOT_EXT_RAM() { \
|
_ATOMIC_IF_NOT_EXT_RAM() { \
|
||||||
void __sync_s32c1i_lock_release_ ## n (volatile void* ptr); \
|
void __sync_s32c1i_lock_release_ ## n (volatile void* ptr); \
|
||||||
__sync_s32c1i_lock_release_ ## n (ptr); \
|
__sync_s32c1i_lock_release_ ## n (ptr); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#else // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2)
|
#define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2)
|
||||||
#define _ATOMIC_HW_STUB_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_STORE(n, type)
|
#define _ATOMIC_HW_STUB_STORE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_LOAD(n, type)
|
#define _ATOMIC_HW_STUB_LOAD(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type)
|
||||||
|
|
||||||
#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
// Clang doesn't allow to define "__sync_*" atomics. The workaround is to define function with name "__sync_*_builtin",
|
// Clang doesn't allow to define "__sync_*" atomics. The workaround is to define function with name "__sync_*_builtin",
|
||||||
// which implements "__sync_*" atomic functionality and use asm directive to set the value of symbol "__sync_*" to the name
|
// which implements "__sync_*" atomic functionality and use asm directive to set the value of symbol "__sync_*" to the name
|
||||||
// of defined function.
|
// of defined function.
|
||||||
|
|
||||||
#define CLANG_ATOMIC_SUFFIX(name_) name_ ## _builtin
|
#define CLANG_ATOMIC_SUFFIX(name_) name_ ## _builtin
|
||||||
#define CLANG_DECLARE_ALIAS(name_) \
|
#define CLANG_DECLARE_ALIAS(name_) \
|
||||||
__asm__(".type " # name_ ", @function\n" \
|
__asm__(".type " # name_ ", @function\n" \
|
||||||
".global " #name_ "\n" \
|
".global " #name_ "\n" \
|
||||||
".equ " #name_ ", " #name_ "_builtin");
|
".equ " #name_ ", " #name_ "_builtin");
|
||||||
|
|
||||||
#else // __clang__
|
#else // __clang__
|
||||||
|
|
||||||
#define CLANG_ATOMIC_SUFFIX(name_) name_
|
#define CLANG_ATOMIC_SUFFIX(name_) name_
|
||||||
#define CLANG_DECLARE_ALIAS(name_)
|
#define CLANG_DECLARE_ALIAS(name_)
|
||||||
|
|
||||||
#endif // __clang__
|
#endif // __clang__
|
||||||
|
|
||||||
#define ATOMIC_OP_FUNCTIONS(n, type, name, operation, inverse) \
|
#define ATOMIC_OP_FUNCTIONS(n, type, name, operation, inverse) \
|
||||||
_ATOMIC_OP_FUNCTION(n, type, fetch, name, old, operation, inverse) \
|
_ATOMIC_OP_FUNCTION(n, type, fetch, name, old, operation, inverse) \
|
||||||
_ATOMIC_OP_FUNCTION(n, type, name, fetch, new, operation, inverse)
|
_ATOMIC_OP_FUNCTION(n, type, name, fetch, new, operation, inverse)
|
||||||
|
|
||||||
#define _ATOMIC_OP_FUNCTION(n, type, name_1, name_2, ret_var, operation, inverse) \
|
#define _ATOMIC_OP_FUNCTION(n, type, name_1, name_2, ret_var, operation, inverse) \
|
||||||
type __atomic_ ##name_1 ##_ ##name_2 ##_ ##n (volatile void* ptr, type value, int memorder) \
|
type __atomic_ ##name_1 ##_ ##name_2 ##_ ##n (volatile void* ptr, type value, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
type old, new; \
|
type old, new; \
|
||||||
_ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2); \
|
_ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
old = (*(volatile type*)ptr); \
|
old = (*(volatile type*)ptr); \
|
||||||
new = inverse(old operation value); \
|
new = inverse(old operation value); \
|
||||||
*(volatile type*)ptr = new; \
|
*(volatile type*)ptr = new; \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return ret_var; \
|
return ret_var; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_LOAD(n, type) \
|
#define ATOMIC_LOAD(n, type) \
|
||||||
type __atomic_load_ ## n (const volatile void* ptr, int memorder) \
|
type __atomic_load_ ## n (const volatile void* ptr, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
type old; \
|
type old; \
|
||||||
_ATOMIC_HW_STUB_LOAD(n, type); \
|
_ATOMIC_HW_STUB_LOAD(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
old = *(const volatile type*)ptr; \
|
old = *(const volatile type*)ptr; \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return old; \
|
return old; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_CMP_EXCHANGE(n, type) \
|
#define ATOMIC_CMP_EXCHANGE(n, type) \
|
||||||
bool __atomic_compare_exchange_ ## n (volatile void* ptr, void* expected, type desired, bool weak, int success, int failure) \
|
bool __atomic_compare_exchange_ ## n (volatile void* ptr, void* expected, type desired, bool weak, int success, int failure) \
|
||||||
{ \
|
{ \
|
||||||
bool ret = false; \
|
bool ret = false; \
|
||||||
_ATOMIC_HW_STUB_CMP_EXCHANGE(n, type); \
|
_ATOMIC_HW_STUB_CMP_EXCHANGE(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
if (*(volatile type*)ptr == *(type*)expected) { \
|
if (*(volatile type*)ptr == *(type*)expected) { \
|
||||||
ret = true; \
|
ret = true; \
|
||||||
*(volatile type*)ptr = desired; \
|
*(volatile type*)ptr = desired; \
|
||||||
} else { \
|
} else { \
|
||||||
*(type*)expected = *(volatile type*)ptr; \
|
*(type*)expected = *(volatile type*)ptr; \
|
||||||
} \
|
} \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_STORE(n, type) \
|
#define ATOMIC_STORE(n, type) \
|
||||||
void __atomic_store_ ## n (volatile void * ptr, type value, int memorder) \
|
void __atomic_store_ ## n (volatile void * ptr, type value, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
_ATOMIC_HW_STUB_STORE(n, type); \
|
_ATOMIC_HW_STUB_STORE(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
*(volatile type*)ptr = value; \
|
*(volatile type*)ptr = value; \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ATOMIC_EXCHANGE(n, type) \
|
#define ATOMIC_EXCHANGE(n, type) \
|
||||||
type __atomic_exchange_ ## n (volatile void* ptr, type value, int memorder) \
|
type __atomic_exchange_ ## n (volatile void* ptr, type value, int memorder) \
|
||||||
{ \
|
{ \
|
||||||
type old; \
|
type old; \
|
||||||
_ATOMIC_HW_STUB_EXCHANGE(n, type); \
|
_ATOMIC_HW_STUB_EXCHANGE(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
old = *(volatile type*)ptr; \
|
old = *(volatile type*)ptr; \
|
||||||
*(volatile type*)ptr = value; \
|
*(volatile type*)ptr = value; \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return old; \
|
return old; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SYNC_OP_FUNCTIONS(n, type, name) \
|
#define SYNC_OP_FUNCTIONS(n, type, name) \
|
||||||
_SYNC_OP_FUNCTION(n, type, fetch, name) \
|
_SYNC_OP_FUNCTION(n, type, fetch, name) \
|
||||||
_SYNC_OP_FUNCTION(n, type, name, fetch)
|
_SYNC_OP_FUNCTION(n, type, name, fetch)
|
||||||
|
|
||||||
#define _SYNC_OP_FUNCTION(n, type, name_1, name_2) \
|
#define _SYNC_OP_FUNCTION(n, type, name_1, name_2) \
|
||||||
type CLANG_ATOMIC_SUFFIX(__sync_ ##name_1 ##_and_ ##name_2 ##_ ##n) (volatile void* ptr, type value) \
|
type CLANG_ATOMIC_SUFFIX(__sync_ ##name_1 ##_and_ ##name_2 ##_ ##n) (volatile void* ptr, type value) \
|
||||||
{ \
|
{ \
|
||||||
return __atomic_ ##name_1 ##_ ##name_2 ##_ ##n (ptr, value, __ATOMIC_SEQ_CST); \
|
return __atomic_ ##name_1 ##_ ##name_2 ##_ ##n (ptr, value, __ATOMIC_SEQ_CST); \
|
||||||
} \
|
} \
|
||||||
CLANG_DECLARE_ALIAS( __sync_##name_1 ##_and_ ##name_2 ##_ ##n )
|
CLANG_DECLARE_ALIAS( __sync_##name_1 ##_and_ ##name_2 ##_ ##n )
|
||||||
|
|
||||||
#define SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
#define SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
||||||
bool CLANG_ATOMIC_SUFFIX(__sync_bool_compare_and_swap_ ## n) (volatile void* ptr, type expected, type desired) \
|
bool CLANG_ATOMIC_SUFFIX(__sync_bool_compare_and_swap_ ## n) (volatile void* ptr, type expected, type desired) \
|
||||||
{ \
|
{ \
|
||||||
bool ret = false; \
|
bool ret = false; \
|
||||||
_ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type); \
|
_ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
if (*(volatile type*)ptr == expected) { \
|
if (*(volatile type*)ptr == expected) { \
|
||||||
*(volatile type*)ptr = desired; \
|
*(volatile type*)ptr = desired; \
|
||||||
ret = true; \
|
ret = true; \
|
||||||
} \
|
} \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return ret; \
|
return ret; \
|
||||||
} \
|
} \
|
||||||
CLANG_DECLARE_ALIAS( __sync_bool_compare_and_swap_ ## n )
|
CLANG_DECLARE_ALIAS( __sync_bool_compare_and_swap_ ## n )
|
||||||
|
|
||||||
#define SYNC_VAL_CMP_EXCHANGE(n, type) \
|
#define SYNC_VAL_CMP_EXCHANGE(n, type) \
|
||||||
type CLANG_ATOMIC_SUFFIX(__sync_val_compare_and_swap_ ## n) (volatile void* ptr, type expected, type desired) \
|
type CLANG_ATOMIC_SUFFIX(__sync_val_compare_and_swap_ ## n) (volatile void* ptr, type expected, type desired) \
|
||||||
{ \
|
{ \
|
||||||
type old; \
|
type old; \
|
||||||
_ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type); \
|
_ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
old = *(volatile type*)ptr; \
|
old = *(volatile type*)ptr; \
|
||||||
if (old == expected) { \
|
if (old == expected) { \
|
||||||
*(volatile type*)ptr = desired; \
|
*(volatile type*)ptr = desired; \
|
||||||
} \
|
} \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return old; \
|
return old; \
|
||||||
} \
|
} \
|
||||||
CLANG_DECLARE_ALIAS( __sync_val_compare_and_swap_ ## n )
|
CLANG_DECLARE_ALIAS( __sync_val_compare_and_swap_ ## n )
|
||||||
|
|
||||||
#define SYNC_LOCK_TEST_AND_SET(n, type) \
|
#define SYNC_LOCK_TEST_AND_SET(n, type) \
|
||||||
type CLANG_ATOMIC_SUFFIX(__sync_lock_test_and_set_ ## n) (volatile void* ptr, type value) \
|
type CLANG_ATOMIC_SUFFIX(__sync_lock_test_and_set_ ## n) (volatile void* ptr, type value) \
|
||||||
{ \
|
{ \
|
||||||
type old; \
|
type old; \
|
||||||
_ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type); \
|
_ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
old = *(volatile type*)ptr; \
|
old = *(volatile type*)ptr; \
|
||||||
*(volatile type*)ptr = value; \
|
*(volatile type*)ptr = value; \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
return old; \
|
return old; \
|
||||||
} \
|
} \
|
||||||
CLANG_DECLARE_ALIAS( __sync_lock_test_and_set_ ## n )
|
CLANG_DECLARE_ALIAS( __sync_lock_test_and_set_ ## n )
|
||||||
|
|
||||||
#define SYNC_LOCK_RELEASE(n, type) \
|
#define SYNC_LOCK_RELEASE(n, type) \
|
||||||
void CLANG_ATOMIC_SUFFIX(__sync_lock_release_ ## n) (volatile void* ptr) \
|
void CLANG_ATOMIC_SUFFIX(__sync_lock_release_ ## n) (volatile void* ptr) \
|
||||||
{ \
|
{ \
|
||||||
_ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type); \
|
_ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type); \
|
||||||
_ATOMIC_ENTER_CRITICAL(); \
|
_ATOMIC_ENTER_CRITICAL(); \
|
||||||
*(volatile type*)ptr = 0; \
|
*(volatile type*)ptr = 0; \
|
||||||
_ATOMIC_EXIT_CRITICAL(); \
|
_ATOMIC_EXIT_CRITICAL(); \
|
||||||
} \
|
} \
|
||||||
CLANG_DECLARE_ALIAS( __sync_lock_release_ ## n )
|
CLANG_DECLARE_ALIAS( __sync_lock_release_ ## n )
|
||||||
|
|
||||||
#define ATOMIC_FUNCTIONS(n, type) \
|
#define ATOMIC_FUNCTIONS(n, type) \
|
||||||
ATOMIC_EXCHANGE(n, type) \
|
ATOMIC_EXCHANGE(n, type) \
|
||||||
ATOMIC_CMP_EXCHANGE(n, type) \
|
ATOMIC_CMP_EXCHANGE(n, type) \
|
||||||
ATOMIC_OP_FUNCTIONS(n, type, add, +, ) \
|
ATOMIC_OP_FUNCTIONS(n, type, add, +, ) \
|
||||||
ATOMIC_OP_FUNCTIONS(n, type, sub, -, ) \
|
ATOMIC_OP_FUNCTIONS(n, type, sub, -, ) \
|
||||||
ATOMIC_OP_FUNCTIONS(n, type, and, &, ) \
|
ATOMIC_OP_FUNCTIONS(n, type, and, &, ) \
|
||||||
ATOMIC_OP_FUNCTIONS(n, type, or, |, ) \
|
ATOMIC_OP_FUNCTIONS(n, type, or, |, ) \
|
||||||
ATOMIC_OP_FUNCTIONS(n, type, xor, ^, ) \
|
ATOMIC_OP_FUNCTIONS(n, type, xor, ^, ) \
|
||||||
ATOMIC_OP_FUNCTIONS(n, type, nand, &, ~) \
|
ATOMIC_OP_FUNCTIONS(n, type, nand, &, ~) \
|
||||||
/* LLVM has not implemented native atomic load/stores for riscv targets without the Atomic extension. LLVM thread: https://reviews.llvm.org/D47553. \
|
/* LLVM has not implemented native atomic load/stores for riscv targets without the Atomic extension. LLVM thread: https://reviews.llvm.org/D47553. \
|
||||||
* Even though GCC does transform them, these libcalls need to be available for the case where a LLVM based project links against IDF. */ \
|
* Even though GCC does transform them, these libcalls need to be available for the case where a LLVM based project links against IDF. */ \
|
||||||
ATOMIC_LOAD(n, type) \
|
ATOMIC_LOAD(n, type) \
|
||||||
ATOMIC_STORE(n, type) \
|
ATOMIC_STORE(n, type) \
|
||||||
SYNC_OP_FUNCTIONS(n, type, add) \
|
SYNC_OP_FUNCTIONS(n, type, add) \
|
||||||
SYNC_OP_FUNCTIONS(n, type, sub) \
|
SYNC_OP_FUNCTIONS(n, type, sub) \
|
||||||
SYNC_OP_FUNCTIONS(n, type, and) \
|
SYNC_OP_FUNCTIONS(n, type, and) \
|
||||||
SYNC_OP_FUNCTIONS(n, type, or) \
|
SYNC_OP_FUNCTIONS(n, type, or) \
|
||||||
SYNC_OP_FUNCTIONS(n, type, xor) \
|
SYNC_OP_FUNCTIONS(n, type, xor) \
|
||||||
SYNC_OP_FUNCTIONS(n, type, nand) \
|
SYNC_OP_FUNCTIONS(n, type, nand) \
|
||||||
SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
SYNC_BOOL_CMP_EXCHANGE(n, type) \
|
||||||
SYNC_VAL_CMP_EXCHANGE(n, type) \
|
SYNC_VAL_CMP_EXCHANGE(n, type) \
|
||||||
SYNC_LOCK_TEST_AND_SET(n, type) \
|
SYNC_LOCK_TEST_AND_SET(n, type) \
|
||||||
SYNC_LOCK_RELEASE(n, type)
|
SYNC_LOCK_RELEASE(n, type)
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void esp_time_impl_init(void);
|
void esp_time_impl_init(void);
|
||||||
|
|
||||||
uint64_t esp_time_impl_get_time(void);
|
uint64_t esp_time_impl_get_time(void);
|
||||||
|
|
||||||
uint64_t esp_time_impl_get_time_since_boot(void);
|
uint64_t esp_time_impl_get_time_since_boot(void);
|
||||||
|
|
||||||
uint32_t esp_time_impl_get_time_resolution(void);
|
uint32_t esp_time_impl_get_time_resolution(void);
|
||||||
|
|
||||||
void esp_time_impl_set_boot_time(uint64_t t);
|
void esp_time_impl_set_boot_time(uint64_t t);
|
||||||
|
|
||||||
uint64_t esp_time_impl_get_boot_time(void);
|
uint64_t esp_time_impl_get_boot_time(void);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
||||||
idf_build_set_property(COMPILE_OPTIONS "-mdisable-hardware-atomics" APPEND)
|
idf_build_set_property(COMPILE_OPTIONS "-mdisable-hardware-atomics" APPEND)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
+37
-37
@@ -1,37 +1,37 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
const static char *TAG = "esp32_asio_pthread";
|
const static char *TAG = "esp32_asio_pthread";
|
||||||
|
|
||||||
int pthread_setcancelstate(int state, int *oldstate)
|
int pthread_setcancelstate(int state, int *oldstate)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This functions (pthread_sigmask(), sigfillset) are called from ASIO::signal_blocker to temporarily silence signals
|
// This functions (pthread_sigmask(), sigfillset) are called from ASIO::signal_blocker to temporarily silence signals
|
||||||
// Since signals are not yet supported in ESP pthread these functions serve as no-ops
|
// Since signals are not yet supported in ESP pthread these functions serve as no-ops
|
||||||
//
|
//
|
||||||
int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oset)
|
int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict oset)
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "%s: Signals not supported in ESP pthread", __func__);
|
ESP_LOGD(TAG, "%s: Signals not supported in ESP pthread", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sigfillset(sigset_t *what)
|
int sigfillset(sigset_t *what)
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "%s: Signals not supported in ESP pthread", __func__);
|
ESP_LOGD(TAG, "%s: Signals not supported in ESP pthread", __func__);
|
||||||
if (what != NULL) {
|
if (what != NULL) {
|
||||||
*what = ~0;
|
*what = ~0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void newlib_include_pthread_impl(void)
|
void newlib_include_pthread_impl(void)
|
||||||
{
|
{
|
||||||
// Linker hook, exists for no other purpose
|
// Linker hook, exists for no other purpose
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-35
@@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "esp_random.h"
|
#include "esp_random.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char *TAG = "RANDOM";
|
static const char *TAG = "RANDOM";
|
||||||
|
|
||||||
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)
|
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)
|
||||||
{
|
{
|
||||||
// Flags are ignored because:
|
// Flags are ignored because:
|
||||||
// - esp_random is non-blocking so it works for both blocking and non-blocking calls,
|
// - esp_random is non-blocking so it works for both blocking and non-blocking calls,
|
||||||
// - don't have opportunity so set som other source of entropy.
|
// - don't have opportunity so set som other source of entropy.
|
||||||
|
|
||||||
ESP_LOGD(TAG, "getrandom(buf=0x%x, buflen=%d, flags=%u)", (int) buf, buflen, flags);
|
ESP_LOGD(TAG, "getrandom(buf=0x%x, buflen=%d, flags=%u)", (int) buf, buflen, flags);
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
ESP_LOGD(TAG, "getrandom returns -1 (EFAULT)");
|
ESP_LOGD(TAG, "getrandom returns -1 (EFAULT)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_fill_random(buf, buflen);
|
esp_fill_random(buf, buflen);
|
||||||
|
|
||||||
ESP_LOGD(TAG, "getrandom returns %d", buflen);
|
ESP_LOGD(TAG, "getrandom returns %d", buflen);
|
||||||
return buflen;
|
return buflen;
|
||||||
}
|
}
|
||||||
|
|||||||
+124
-124
@@ -1,124 +1,124 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
/* realpath logic:
|
/* realpath logic:
|
||||||
* 1. prepend CWD (/)
|
* 1. prepend CWD (/)
|
||||||
* 2. iterate over components (search until next '/' or end of line)
|
* 2. iterate over components (search until next '/' or end of line)
|
||||||
* - empty, skip the component
|
* - empty, skip the component
|
||||||
* - if it is '.', skip the component
|
* - if it is '.', skip the component
|
||||||
* - if it is '..'
|
* - if it is '..'
|
||||||
* - and out_level == 0, ??? ('/..')
|
* - and out_level == 0, ??? ('/..')
|
||||||
* - otherwise, reverse-search for '/', set out_pos to that - 1, decrement out_level
|
* - otherwise, reverse-search for '/', set out_pos to that - 1, decrement out_level
|
||||||
* - otherwise, add the component to output, increment out_level
|
* - otherwise, add the component to output, increment out_level
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char * realpath(const char *file_name, char *resolved_name)
|
char * realpath(const char *file_name, char *resolved_name)
|
||||||
{
|
{
|
||||||
char * out_path = resolved_name;
|
char * out_path = resolved_name;
|
||||||
if (out_path == NULL) {
|
if (out_path == NULL) {
|
||||||
/* allowed as an extension, allocate memory for the output path */
|
/* allowed as an extension, allocate memory for the output path */
|
||||||
out_path = malloc(PATH_MAX);
|
out_path = malloc(PATH_MAX);
|
||||||
if (out_path == NULL) {
|
if (out_path == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* canonical path starts with / */
|
/* canonical path starts with / */
|
||||||
strlcpy(out_path, "/", PATH_MAX);
|
strlcpy(out_path, "/", PATH_MAX);
|
||||||
|
|
||||||
/* pointers moving over the input and output path buffers */
|
/* pointers moving over the input and output path buffers */
|
||||||
const char* in_ptr = file_name;
|
const char* in_ptr = file_name;
|
||||||
char* out_ptr = out_path + 1;
|
char* out_ptr = out_path + 1;
|
||||||
/* number of path components in the output buffer */
|
/* number of path components in the output buffer */
|
||||||
size_t out_depth = 0;
|
size_t out_depth = 0;
|
||||||
|
|
||||||
while (*in_ptr) {
|
while (*in_ptr) {
|
||||||
/* "path component" is the part between two '/' path separators.
|
/* "path component" is the part between two '/' path separators.
|
||||||
* locate the next path component in the input path:
|
* locate the next path component in the input path:
|
||||||
*/
|
*/
|
||||||
const char* end_of_path_component = strchrnul(in_ptr, '/');
|
const char* end_of_path_component = strchrnul(in_ptr, '/');
|
||||||
size_t path_component_len = end_of_path_component - in_ptr;
|
size_t path_component_len = end_of_path_component - in_ptr;
|
||||||
|
|
||||||
if (path_component_len == 0 ||
|
if (path_component_len == 0 ||
|
||||||
(path_component_len == 1 && in_ptr[0] == '.')) {
|
(path_component_len == 1 && in_ptr[0] == '.')) {
|
||||||
/* empty path component or '.' - nothing to do */
|
/* empty path component or '.' - nothing to do */
|
||||||
} else if (path_component_len == 2 && in_ptr[0] == '.' && in_ptr[1] == '.') {
|
} else if (path_component_len == 2 && in_ptr[0] == '.' && in_ptr[1] == '.') {
|
||||||
/* '..' - remove one path component from the output */
|
/* '..' - remove one path component from the output */
|
||||||
if (out_depth == 0) {
|
if (out_depth == 0) {
|
||||||
/* nothing to remove */
|
/* nothing to remove */
|
||||||
} else if (out_depth == 1) {
|
} else if (out_depth == 1) {
|
||||||
/* there is only one path component in output;
|
/* there is only one path component in output;
|
||||||
* remove it, but keep the leading separator
|
* remove it, but keep the leading separator
|
||||||
*/
|
*/
|
||||||
out_ptr = out_path + 1;
|
out_ptr = out_path + 1;
|
||||||
*out_ptr = '\0';
|
*out_ptr = '\0';
|
||||||
out_depth = 0;
|
out_depth = 0;
|
||||||
} else {
|
} else {
|
||||||
/* remove last path component and the separator preceding it */
|
/* remove last path component and the separator preceding it */
|
||||||
char * prev_sep = strrchr(out_path, '/');
|
char * prev_sep = strrchr(out_path, '/');
|
||||||
assert(prev_sep > out_path); /* this shouldn't be the leading separator */
|
assert(prev_sep > out_path); /* this shouldn't be the leading separator */
|
||||||
out_ptr = prev_sep;
|
out_ptr = prev_sep;
|
||||||
*out_ptr = '\0';
|
*out_ptr = '\0';
|
||||||
--out_depth;
|
--out_depth;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* copy path component to output; +1 is for the separator */
|
/* copy path component to output; +1 is for the separator */
|
||||||
if (out_ptr - out_path + 1 + path_component_len > PATH_MAX - 1) {
|
if (out_ptr - out_path + 1 + path_component_len > PATH_MAX - 1) {
|
||||||
/* output buffer insufficient */
|
/* output buffer insufficient */
|
||||||
errno = E2BIG;
|
errno = E2BIG;
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
/* add separator if necessary */
|
/* add separator if necessary */
|
||||||
if (out_depth > 0) {
|
if (out_depth > 0) {
|
||||||
*out_ptr = '/';
|
*out_ptr = '/';
|
||||||
++out_ptr;
|
++out_ptr;
|
||||||
}
|
}
|
||||||
memcpy(out_ptr, in_ptr, path_component_len);
|
memcpy(out_ptr, in_ptr, path_component_len);
|
||||||
out_ptr += path_component_len;
|
out_ptr += path_component_len;
|
||||||
*out_ptr = '\0';
|
*out_ptr = '\0';
|
||||||
++out_depth;
|
++out_depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* move input pointer to separator right after this path component */
|
/* move input pointer to separator right after this path component */
|
||||||
in_ptr += path_component_len;
|
in_ptr += path_component_len;
|
||||||
if (*in_ptr != '\0') {
|
if (*in_ptr != '\0') {
|
||||||
/* move past it unless already at the end of the input string */
|
/* move past it unless already at the end of the input string */
|
||||||
++in_ptr;
|
++in_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return out_path;
|
return out_path;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (resolved_name == NULL) {
|
if (resolved_name == NULL) {
|
||||||
/* out_path was allocated, free it */
|
/* out_path was allocated, free it */
|
||||||
free(out_path);
|
free(out_path);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * getcwd(char *buf, size_t size)
|
char * getcwd(char *buf, size_t size)
|
||||||
{
|
{
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return strdup("/");
|
return strdup("/");
|
||||||
}
|
}
|
||||||
strlcpy(buf, "/", size);
|
strlcpy(buf, "/", size);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int chdir(const char *path)
|
int chdir(const char *path)
|
||||||
{
|
{
|
||||||
(void) path;
|
(void) path;
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+75
-75
@@ -1,75 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the replacement for newlib's _REENT_INIT_PTR and __sinit.
|
* This is the replacement for newlib's _REENT_INIT_PTR and __sinit.
|
||||||
* The problem with __sinit is that it allocates three FILE structures
|
* The problem with __sinit is that it allocates three FILE structures
|
||||||
* (stdin, stdout, stderr). Having individual standard streams for each task
|
* (stdin, stdout, stderr). Having individual standard streams for each task
|
||||||
* is a bit too much on a small embedded system. So we point streams
|
* is a bit too much on a small embedded system. So we point streams
|
||||||
* to the streams of the global struct _reent, which are initialized in
|
* to the streams of the global struct _reent, which are initialized in
|
||||||
* startup code.
|
* startup code.
|
||||||
*/
|
*/
|
||||||
void IRAM_ATTR esp_reent_init(struct _reent* r)
|
void IRAM_ATTR esp_reent_init(struct _reent* r)
|
||||||
{
|
{
|
||||||
memset(r, 0, sizeof(*r));
|
memset(r, 0, sizeof(*r));
|
||||||
_REENT_STDIN(r) = _REENT_STDIN(_GLOBAL_REENT);
|
_REENT_STDIN(r) = _REENT_STDIN(_GLOBAL_REENT);
|
||||||
_REENT_STDOUT(r) = _REENT_STDOUT(_GLOBAL_REENT);
|
_REENT_STDOUT(r) = _REENT_STDOUT(_GLOBAL_REENT);
|
||||||
_REENT_STDERR(r) = _REENT_STDERR(_GLOBAL_REENT);
|
_REENT_STDERR(r) = _REENT_STDERR(_GLOBAL_REENT);
|
||||||
_REENT_CLEANUP(r) = _REENT_CLEANUP(_GLOBAL_REENT);
|
_REENT_CLEANUP(r) = _REENT_CLEANUP(_GLOBAL_REENT);
|
||||||
_REENT_SDIDINIT(r) = _REENT_SDIDINIT(_GLOBAL_REENT);
|
_REENT_SDIDINIT(r) = _REENT_SDIDINIT(_GLOBAL_REENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only declared in private stdio header file, local.h */
|
/* only declared in private stdio header file, local.h */
|
||||||
extern void __sfp_lock_acquire(void);
|
extern void __sfp_lock_acquire(void);
|
||||||
extern void __sfp_lock_release(void);
|
extern void __sfp_lock_release(void);
|
||||||
|
|
||||||
void esp_reent_cleanup(void)
|
void esp_reent_cleanup(void)
|
||||||
{
|
{
|
||||||
struct _reent* r = __getreent();
|
struct _reent* r = __getreent();
|
||||||
_reclaim_reent(r);
|
_reclaim_reent(r);
|
||||||
|
|
||||||
r->_emergency = NULL;
|
r->_emergency = NULL;
|
||||||
r->_mp = NULL;
|
r->_mp = NULL;
|
||||||
r->_r48 = NULL;
|
r->_r48 = NULL;
|
||||||
r->_localtime_buf = NULL;
|
r->_localtime_buf = NULL;
|
||||||
r->_asctime_buf = NULL;
|
r->_asctime_buf = NULL;
|
||||||
r->_signal_buf = NULL;
|
r->_signal_buf = NULL;
|
||||||
r->_misc = NULL;
|
r->_misc = NULL;
|
||||||
r->_cvtbuf = NULL;
|
r->_cvtbuf = NULL;
|
||||||
|
|
||||||
/* Clean up "glue" (lazily-allocated FILE objects) */
|
/* Clean up "glue" (lazily-allocated FILE objects) */
|
||||||
struct _glue* prev = &_REENT_SGLUE(_GLOBAL_REENT);
|
struct _glue* prev = &_REENT_SGLUE(_GLOBAL_REENT);
|
||||||
for (struct _glue * cur = _REENT_SGLUE(_GLOBAL_REENT)._next; cur != NULL;) {
|
for (struct _glue * cur = _REENT_SGLUE(_GLOBAL_REENT)._next; cur != NULL;) {
|
||||||
if (cur->_niobs == 0) {
|
if (cur->_niobs == 0) {
|
||||||
cur = cur->_next;
|
cur = cur->_next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool has_open_files = false;
|
bool has_open_files = false;
|
||||||
for (int i = 0; i < cur->_niobs; ++i) {
|
for (int i = 0; i < cur->_niobs; ++i) {
|
||||||
FILE* fp = &cur->_iobs[i];
|
FILE* fp = &cur->_iobs[i];
|
||||||
if (fp->_flags != 0) {
|
if (fp->_flags != 0) {
|
||||||
has_open_files = true;
|
has_open_files = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (has_open_files) {
|
if (has_open_files) {
|
||||||
prev = cur;
|
prev = cur;
|
||||||
cur = cur->_next;
|
cur = cur->_next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
struct _glue * next = cur->_next;
|
struct _glue * next = cur->_next;
|
||||||
prev->_next = next;
|
prev->_next = next;
|
||||||
free(cur);
|
free(cur);
|
||||||
cur = next;
|
cur = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: 'newlib'
|
name: 'newlib'
|
||||||
version: '4.3.0'
|
version: '4.3.0'
|
||||||
cpe: cpe:2.3:a:newlib_project:newlib:{}:*:*:*:*:*:*:*
|
cpe: cpe:2.3:a:newlib_project:newlib:{}:*:*:*:*:*:*:*
|
||||||
supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
|
supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
|
||||||
originator: 'Organization: Red Hat Incorporated'
|
originator: 'Organization: Red Hat Incorporated'
|
||||||
description: An open-source C standard library implementation with additional features and patches from Espressif.
|
description: An open-source C standard library implementation with additional features and patches from Espressif.
|
||||||
|
|||||||
+81
-81
@@ -1,81 +1,81 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char *TAG = "scandir";
|
static const char *TAG = "scandir";
|
||||||
|
|
||||||
int alphasort(const struct dirent **lhs, const struct dirent **rhs)
|
int alphasort(const struct dirent **lhs, const struct dirent **rhs)
|
||||||
{
|
{
|
||||||
return strcoll((*lhs)->d_name, (*rhs)->d_name);
|
return strcoll((*lhs)->d_name, (*rhs)->d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int scandir(const char *dirname, struct dirent ***out_dirlist,
|
int scandir(const char *dirname, struct dirent ***out_dirlist,
|
||||||
int (*select_func)(const struct dirent *),
|
int (*select_func)(const struct dirent *),
|
||||||
int (*cmp_func)(const struct dirent **, const struct dirent **))
|
int (*cmp_func)(const struct dirent **, const struct dirent **))
|
||||||
{
|
{
|
||||||
DIR *dir_ptr = NULL;
|
DIR *dir_ptr = NULL;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
size_t num_entries = 0;
|
size_t num_entries = 0;
|
||||||
size_t array_size = 8; /* initial estimate */
|
size_t array_size = 8; /* initial estimate */
|
||||||
struct dirent **entries = NULL;
|
struct dirent **entries = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
entries = malloc(array_size * sizeof(struct dirent *));
|
entries = malloc(array_size * sizeof(struct dirent *));
|
||||||
ESP_RETURN_ON_FALSE(entries, -1, TAG, "Malloc failed for entries");
|
ESP_RETURN_ON_FALSE(entries, -1, TAG, "Malloc failed for entries");
|
||||||
|
|
||||||
dir_ptr = opendir(dirname);
|
dir_ptr = opendir(dirname);
|
||||||
ESP_GOTO_ON_FALSE(dir_ptr, -1, out, TAG, "Failed to open directory: %s", dirname);
|
ESP_GOTO_ON_FALSE(dir_ptr, -1, out, TAG, "Failed to open directory: %s", dirname);
|
||||||
|
|
||||||
while ((entry = readdir(dir_ptr)) != NULL) {
|
while ((entry = readdir(dir_ptr)) != NULL) {
|
||||||
/* skip entries that don't match the filter function */
|
/* skip entries that don't match the filter function */
|
||||||
if (select_func != NULL && !select_func(entry)) {
|
if (select_func != NULL && !select_func(entry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dirent *entry_copy = malloc(sizeof(struct dirent));
|
struct dirent *entry_copy = malloc(sizeof(struct dirent));
|
||||||
ESP_GOTO_ON_FALSE(entry_copy, -1, out, TAG, "Malloc failed for entry_copy");
|
ESP_GOTO_ON_FALSE(entry_copy, -1, out, TAG, "Malloc failed for entry_copy");
|
||||||
|
|
||||||
*entry_copy = *entry;
|
*entry_copy = *entry;
|
||||||
entries[num_entries++] = entry_copy;
|
entries[num_entries++] = entry_copy;
|
||||||
|
|
||||||
/* grow the array size if it's full */
|
/* grow the array size if it's full */
|
||||||
if (num_entries >= array_size) {
|
if (num_entries >= array_size) {
|
||||||
array_size *= 2;
|
array_size *= 2;
|
||||||
struct dirent **new_entries = realloc(entries, array_size * sizeof(struct dirent *));
|
struct dirent **new_entries = realloc(entries, array_size * sizeof(struct dirent *));
|
||||||
ESP_GOTO_ON_FALSE(new_entries, -1, out, TAG, "Realloc failed for entries");
|
ESP_GOTO_ON_FALSE(new_entries, -1, out, TAG, "Realloc failed for entries");
|
||||||
entries = new_entries;
|
entries = new_entries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sort the entries if a comparison function is provided */
|
/* sort the entries if a comparison function is provided */
|
||||||
if (num_entries && cmp_func) {
|
if (num_entries && cmp_func) {
|
||||||
qsort(entries, num_entries, sizeof(struct dirent *),
|
qsort(entries, num_entries, sizeof(struct dirent *),
|
||||||
(int (*)(const void *, const void *))cmp_func);
|
(int (*)(const void *, const void *))cmp_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_dirlist = entries;
|
*out_dirlist = entries;
|
||||||
ret = num_entries;
|
ret = num_entries;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
while (num_entries > 0) {
|
while (num_entries > 0) {
|
||||||
free(entries[--num_entries]);
|
free(entries[--num_entries]);
|
||||||
}
|
}
|
||||||
free(entries);
|
free(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak") // Ignore intended return of allocated *out_dirlist
|
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak") // Ignore intended return of allocated *out_dirlist
|
||||||
if (dir_ptr) {
|
if (dir_ptr) {
|
||||||
closedir(dir_ptr);
|
closedir(dir_ptr);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
|
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# sdkconfig replacement configurations for deprecated options formatted as
|
# sdkconfig replacement configurations for deprecated options formatted as
|
||||||
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
||||||
|
|
||||||
CONFIG_ESP32_TIME_SYSCALL_USE_RTC_HRT CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32_TIME_SYSCALL_USE_RTC_HRT CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
CONFIG_ESP32_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
||||||
CONFIG_ESP32_TIME_SYSCALL_USE_HRT CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32_TIME_SYSCALL_USE_HRT CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
CONFIG_ESP32_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
CONFIG_ESP32_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
||||||
CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# sdkconfig replacement configurations for deprecated options formatted as
|
# sdkconfig replacement configurations for deprecated options formatted as
|
||||||
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
||||||
|
|
||||||
CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
||||||
CONFIG_ESP32C3_TIME_SYSCALL_USE_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32C3_TIME_SYSCALL_USE_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
CONFIG_ESP32C3_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
CONFIG_ESP32C3_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# sdkconfig replacement configurations for deprecated options formatted as
|
# sdkconfig replacement configurations for deprecated options formatted as
|
||||||
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
||||||
|
|
||||||
CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
||||||
CONFIG_ESP32S2_TIME_SYSCALL_USE_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32S2_TIME_SYSCALL_USE_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
CONFIG_ESP32S2_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
CONFIG_ESP32S2_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
||||||
CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32S2_TIME_SYSCALL_USE_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32S2_TIME_SYSCALL_USE_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# sdkconfig replacement configurations for deprecated options formatted as
|
# sdkconfig replacement configurations for deprecated options formatted as
|
||||||
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
||||||
|
|
||||||
CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC
|
||||||
CONFIG_ESP32S3_TIME_SYSCALL_USE_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32S3_TIME_SYSCALL_USE_SYSTIMER CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE
|
||||||
CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT
|
||||||
CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT
|
||||||
|
|||||||
+111
-111
@@ -1,111 +1,111 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//replacement for gcc built-in functions
|
//replacement for gcc built-in functions
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "esp_stdatomic.h"
|
#include "esp_stdatomic.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#if SOC_CPU_CORES_NUM > 1
|
#if SOC_CPU_CORES_NUM > 1
|
||||||
#if !CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#if !CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
_Static_assert(HAS_ATOMICS_32, "32-bit atomics should be supported if SOC_CPU_CORES_NUM > 1");
|
_Static_assert(HAS_ATOMICS_32, "32-bit atomics should be supported if SOC_CPU_CORES_NUM > 1");
|
||||||
#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
// Only need to implement 64-bit atomics here. Use a single global portMUX_TYPE spinlock
|
// Only need to implement 64-bit atomics here. Use a single global portMUX_TYPE spinlock
|
||||||
// to emulate the atomics.
|
// to emulate the atomics.
|
||||||
static portMUX_TYPE s_atomic_lock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE s_atomic_lock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAS_ATOMICS_32
|
#if !HAS_ATOMICS_32
|
||||||
|
|
||||||
_Static_assert(sizeof(unsigned char) == 1, "atomics require a 1-byte type");
|
_Static_assert(sizeof(unsigned char) == 1, "atomics require a 1-byte type");
|
||||||
_Static_assert(sizeof(short unsigned int) == 2, "atomics require a 2-bytes type");
|
_Static_assert(sizeof(short unsigned int) == 2, "atomics require a 2-bytes type");
|
||||||
_Static_assert(sizeof(unsigned int) == 4, "atomics require a 4-bytes type");
|
_Static_assert(sizeof(unsigned int) == 4, "atomics require a 4-bytes type");
|
||||||
|
|
||||||
ATOMIC_FUNCTIONS(1, unsigned char)
|
ATOMIC_FUNCTIONS(1, unsigned char)
|
||||||
ATOMIC_FUNCTIONS(2, short unsigned int)
|
ATOMIC_FUNCTIONS(2, short unsigned int)
|
||||||
ATOMIC_FUNCTIONS(4, unsigned int)
|
ATOMIC_FUNCTIONS(4, unsigned int)
|
||||||
|
|
||||||
#elif __riscv_atomic == 1
|
#elif __riscv_atomic == 1
|
||||||
|
|
||||||
bool CLANG_ATOMIC_SUFFIX(__atomic_always_lock_free)(unsigned int size, const volatile void *)
|
bool CLANG_ATOMIC_SUFFIX(__atomic_always_lock_free)(unsigned int size, const volatile void *)
|
||||||
{
|
{
|
||||||
return size <= sizeof(int);
|
return size <= sizeof(int);
|
||||||
}
|
}
|
||||||
CLANG_DECLARE_ALIAS(__atomic_always_lock_free)
|
CLANG_DECLARE_ALIAS(__atomic_always_lock_free)
|
||||||
|
|
||||||
bool CLANG_ATOMIC_SUFFIX(__atomic_is_lock_free)(unsigned int size, const volatile void *)
|
bool CLANG_ATOMIC_SUFFIX(__atomic_is_lock_free)(unsigned int size, const volatile void *)
|
||||||
{
|
{
|
||||||
return size <= sizeof(int);
|
return size <= sizeof(int);
|
||||||
}
|
}
|
||||||
CLANG_DECLARE_ALIAS(__atomic_is_lock_free)
|
CLANG_DECLARE_ALIAS(__atomic_is_lock_free)
|
||||||
|
|
||||||
#endif // !HAS_ATOMICS_32
|
#endif // !HAS_ATOMICS_32
|
||||||
|
|
||||||
#if !HAS_ATOMICS_64
|
#if !HAS_ATOMICS_64
|
||||||
|
|
||||||
#if CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#if CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
#undef _ATOMIC_HW_STUB_OP_FUNCTION
|
#undef _ATOMIC_HW_STUB_OP_FUNCTION
|
||||||
#undef _ATOMIC_HW_STUB_EXCHANGE
|
#undef _ATOMIC_HW_STUB_EXCHANGE
|
||||||
#undef _ATOMIC_HW_STUB_STORE
|
#undef _ATOMIC_HW_STUB_STORE
|
||||||
#undef _ATOMIC_HW_STUB_CMP_EXCHANGE
|
#undef _ATOMIC_HW_STUB_CMP_EXCHANGE
|
||||||
#undef _ATOMIC_HW_STUB_LOAD
|
#undef _ATOMIC_HW_STUB_LOAD
|
||||||
#undef _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE
|
#undef _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE
|
||||||
#undef _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE
|
#undef _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE
|
||||||
#undef _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET
|
#undef _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET
|
||||||
#undef _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE
|
#undef _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE
|
||||||
|
|
||||||
#define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2)
|
#define _ATOMIC_HW_STUB_OP_FUNCTION(n, type, name_1, name_2)
|
||||||
#define _ATOMIC_HW_STUB_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_STORE(n, type)
|
#define _ATOMIC_HW_STUB_STORE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_CMP_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_LOAD(n, type)
|
#define _ATOMIC_HW_STUB_LOAD(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_BOOL_CMP_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_VAL_CMP_EXCHANGE(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_LOCK_TEST_AND_SET(n, type)
|
||||||
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type)
|
#define _ATOMIC_HW_STUB_SYNC_LOCK_RELEASE(n, type)
|
||||||
#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
#endif // CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND
|
||||||
|
|
||||||
_Static_assert(sizeof(long long unsigned int) == 8, "atomics require a 8-bytes type");
|
_Static_assert(sizeof(long long unsigned int) == 8, "atomics require a 8-bytes type");
|
||||||
|
|
||||||
ATOMIC_FUNCTIONS(8, long long unsigned int)
|
ATOMIC_FUNCTIONS(8, long long unsigned int)
|
||||||
|
|
||||||
#endif // !HAS_ATOMICS_64
|
#endif // !HAS_ATOMICS_64
|
||||||
|
|
||||||
// Clang generates calls to the __atomic_load/__atomic_store functions for object size more then 4 bytes
|
// Clang generates calls to the __atomic_load/__atomic_store functions for object size more then 4 bytes
|
||||||
void CLANG_ATOMIC_SUFFIX(__atomic_load)(size_t size, const volatile void *src, void *dest, int model)
|
void CLANG_ATOMIC_SUFFIX(__atomic_load)(size_t size, const volatile void *src, void *dest, int model)
|
||||||
{
|
{
|
||||||
_ATOMIC_ENTER_CRITICAL();
|
_ATOMIC_ENTER_CRITICAL();
|
||||||
memcpy(dest, (const void *)src, size);
|
memcpy(dest, (const void *)src, size);
|
||||||
_ATOMIC_EXIT_CRITICAL();
|
_ATOMIC_EXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
CLANG_DECLARE_ALIAS(__atomic_load)
|
CLANG_DECLARE_ALIAS(__atomic_load)
|
||||||
|
|
||||||
void CLANG_ATOMIC_SUFFIX(__atomic_store)(size_t size, volatile void *dest, void *src, int model)
|
void CLANG_ATOMIC_SUFFIX(__atomic_store)(size_t size, volatile void *dest, void *src, int model)
|
||||||
{
|
{
|
||||||
_ATOMIC_ENTER_CRITICAL();
|
_ATOMIC_ENTER_CRITICAL();
|
||||||
memcpy((void *)dest, (const void *)src, size);
|
memcpy((void *)dest, (const void *)src, size);
|
||||||
_ATOMIC_EXIT_CRITICAL();
|
_ATOMIC_EXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
CLANG_DECLARE_ALIAS(__atomic_store)
|
CLANG_DECLARE_ALIAS(__atomic_store)
|
||||||
|
|
||||||
bool CLANG_ATOMIC_SUFFIX(__atomic_compare_exchange)(size_t size, volatile void *ptr, void *expected, void *desired, int success_memorder, int failure_memorder)
|
bool CLANG_ATOMIC_SUFFIX(__atomic_compare_exchange)(size_t size, volatile void *ptr, void *expected, void *desired, int success_memorder, int failure_memorder)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
_ATOMIC_ENTER_CRITICAL();
|
_ATOMIC_ENTER_CRITICAL();
|
||||||
if (!memcmp((void *)ptr, expected, size)) {
|
if (!memcmp((void *)ptr, expected, size)) {
|
||||||
memcpy((void *)ptr, (const void *)desired, size);
|
memcpy((void *)ptr, (const void *)desired, size);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
memcpy((void *)expected, (const void *)ptr, size);
|
memcpy((void *)expected, (const void *)ptr, size);
|
||||||
}
|
}
|
||||||
_ATOMIC_EXIT_CRITICAL();
|
_ATOMIC_EXIT_CRITICAL();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
CLANG_DECLARE_ALIAS(__atomic_compare_exchange)
|
CLANG_DECLARE_ALIAS(__atomic_compare_exchange)
|
||||||
|
|||||||
+174
-174
@@ -1,174 +1,174 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <reent.h>
|
#include <reent.h>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "esp_rom_uart.h"
|
#include "esp_rom_uart.h"
|
||||||
|
|
||||||
static int syscall_not_implemented(struct _reent *r, ...)
|
static int syscall_not_implemented(struct _reent *r, ...)
|
||||||
{
|
{
|
||||||
__errno_r(r) = ENOSYS;
|
__errno_r(r) = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int syscall_not_implemented_aborts(void)
|
static int syscall_not_implemented_aborts(void)
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t _write_r_console(struct _reent *r, int fd, const void * data, size_t size)
|
ssize_t _write_r_console(struct _reent *r, int fd, const void * data, size_t size)
|
||||||
{
|
{
|
||||||
#if !CONFIG_ESP_CONSOLE_NONE
|
#if !CONFIG_ESP_CONSOLE_NONE
|
||||||
const char* cdata = (const char*) data;
|
const char* cdata = (const char*) data;
|
||||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
esp_rom_output_tx_one_char(cdata[i]);
|
esp_rom_output_tx_one_char(cdata[i]);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
#endif //!CONFIG_ESP_CONSOLE_NONE
|
#endif //!CONFIG_ESP_CONSOLE_NONE
|
||||||
__errno_r(r) = EBADF;
|
__errno_r(r) = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size)
|
ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size)
|
||||||
{
|
{
|
||||||
#if !CONFIG_ESP_CONSOLE_NONE
|
#if !CONFIG_ESP_CONSOLE_NONE
|
||||||
char* cdata = (char*) data;
|
char* cdata = (char*) data;
|
||||||
if (fd == STDIN_FILENO) {
|
if (fd == STDIN_FILENO) {
|
||||||
size_t received;
|
size_t received;
|
||||||
for (received = 0; received < size; ++received) {
|
for (received = 0; received < size; ++received) {
|
||||||
int status = esp_rom_output_rx_one_char((uint8_t*) &cdata[received]);
|
int status = esp_rom_output_rx_one_char((uint8_t*) &cdata[received]);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (received == 0) {
|
if (received == 0) {
|
||||||
errno = EWOULDBLOCK;
|
errno = EWOULDBLOCK;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return received;
|
return received;
|
||||||
}
|
}
|
||||||
#endif //!CONFIG_ESP_CONSOLE_NONE
|
#endif //!CONFIG_ESP_CONSOLE_NONE
|
||||||
__errno_r(r) = EBADF;
|
__errno_r(r) = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t _fstat_r_console(struct _reent *r, int fd, struct stat * st)
|
static ssize_t _fstat_r_console(struct _reent *r, int fd, struct stat * st)
|
||||||
{
|
{
|
||||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||||
memset(st, 0, sizeof(*st));
|
memset(st, 0, sizeof(*st));
|
||||||
/* This needs to be set so that stdout and stderr are line buffered. */
|
/* This needs to be set so that stdout and stderr are line buffered. */
|
||||||
st->st_mode = S_IFCHR;
|
st->st_mode = S_IFCHR;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__errno_r(r) = EBADF;
|
__errno_r(r) = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _fsync_console(int fd)
|
static int _fsync_console(int fd)
|
||||||
{
|
{
|
||||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||||
esp_rom_output_flush_tx(CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM);
|
esp_rom_output_flush_tx(CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following weak definitions of syscalls will be used unless
|
/* The following weak definitions of syscalls will be used unless
|
||||||
* another definition is provided. That definition may come from
|
* another definition is provided. That definition may come from
|
||||||
* VFS, LWIP, or the application.
|
* VFS, LWIP, or the application.
|
||||||
*/
|
*/
|
||||||
ssize_t _read_r(struct _reent *r, int fd, void * dst, size_t size)
|
ssize_t _read_r(struct _reent *r, int fd, void * dst, size_t size)
|
||||||
__attribute__((weak, alias("_read_r_console")));
|
__attribute__((weak, alias("_read_r_console")));
|
||||||
ssize_t _write_r(struct _reent *r, int fd, const void * data, size_t size)
|
ssize_t _write_r(struct _reent *r, int fd, const void * data, size_t size)
|
||||||
__attribute__((weak, alias("_write_r_console")));
|
__attribute__((weak, alias("_write_r_console")));
|
||||||
int _fstat_r(struct _reent *r, int fd, struct stat *st)
|
int _fstat_r(struct _reent *r, int fd, struct stat *st)
|
||||||
__attribute__((weak, alias("_fstat_r_console")));
|
__attribute__((weak, alias("_fstat_r_console")));
|
||||||
int fsync(int fd)
|
int fsync(int fd)
|
||||||
__attribute__((weak, alias("_fsync_console")));
|
__attribute__((weak, alias("_fsync_console")));
|
||||||
|
|
||||||
/* The aliases below are to "syscall_not_implemented", which
|
/* The aliases below are to "syscall_not_implemented", which
|
||||||
* doesn't have the same signature as the original function.
|
* doesn't have the same signature as the original function.
|
||||||
* Disable type mismatch warnings for this reason.
|
* Disable type mismatch warnings for this reason.
|
||||||
*/
|
*/
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wattribute-alias"
|
#pragma GCC diagnostic ignored "-Wattribute-alias"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int _open_r(struct _reent *r, const char * path, int flags, int mode)
|
int _open_r(struct _reent *r, const char * path, int flags, int mode)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _close_r(struct _reent *r, int fd)
|
int _close_r(struct _reent *r, int fd)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
off_t _lseek_r(struct _reent *r, int fd, off_t size, int mode)
|
off_t _lseek_r(struct _reent *r, int fd, off_t size, int mode)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _fcntl_r(struct _reent *r, int fd, int cmd, int arg)
|
int _fcntl_r(struct _reent *r, int fd, int cmd, int arg)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _stat_r(struct _reent *r, const char * path, struct stat * st)
|
int _stat_r(struct _reent *r, const char * path, struct stat * st)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _link_r(struct _reent *r, const char* n1, const char* n2)
|
int _link_r(struct _reent *r, const char* n1, const char* n2)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _unlink_r(struct _reent *r, const char *path)
|
int _unlink_r(struct _reent *r, const char *path)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _rename_r(struct _reent *r, const char *src, const char *dst)
|
int _rename_r(struct _reent *r, const char *src, const char *dst)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
int _isatty_r(struct _reent *r, int fd)
|
int _isatty_r(struct _reent *r, int fd)
|
||||||
__attribute__((weak, alias("syscall_not_implemented")));
|
__attribute__((weak, alias("syscall_not_implemented")));
|
||||||
|
|
||||||
/* These functions are not expected to be overridden */
|
/* These functions are not expected to be overridden */
|
||||||
int _system_r(struct _reent *r, const char *str)
|
int _system_r(struct _reent *r, const char *str)
|
||||||
__attribute__((alias("syscall_not_implemented")));
|
__attribute__((alias("syscall_not_implemented")));
|
||||||
int raise(int sig)
|
int raise(int sig)
|
||||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||||
int _raise_r(struct _reent *r, int sig)
|
int _raise_r(struct _reent *r, int sig)
|
||||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||||
void* _sbrk_r(struct _reent *r, ptrdiff_t sz)
|
void* _sbrk_r(struct _reent *r, ptrdiff_t sz)
|
||||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||||
int _getpid_r(struct _reent *r)
|
int _getpid_r(struct _reent *r)
|
||||||
__attribute__((alias("syscall_not_implemented")));
|
__attribute__((alias("syscall_not_implemented")));
|
||||||
int _kill_r(struct _reent *r, int pid, int sig)
|
int _kill_r(struct _reent *r, int pid, int sig)
|
||||||
__attribute__((alias("syscall_not_implemented")));
|
__attribute__((alias("syscall_not_implemented")));
|
||||||
void _exit(int __status)
|
void _exit(int __status)
|
||||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Similar to syscall_not_implemented, but not taking struct _reent argument */
|
/* Similar to syscall_not_implemented, but not taking struct _reent argument */
|
||||||
int system(const char* str)
|
int system(const char* str)
|
||||||
{
|
{
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replaces newlib fcntl, which has been compiled without HAVE_FCNTL */
|
/* Replaces newlib fcntl, which has been compiled without HAVE_FCNTL */
|
||||||
int fcntl(int fd, int cmd, ...)
|
int fcntl(int fd, int cmd, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, cmd);
|
va_start(args, cmd);
|
||||||
int arg = va_arg(args, int);
|
int arg = va_arg(args, int);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
struct _reent* r = __getreent();
|
struct _reent* r = __getreent();
|
||||||
return _fcntl_r(r, fd, cmd, arg);
|
return _fcntl_r(r, fd, cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No-op function, used to force linking this file,
|
/* No-op function, used to force linking this file,
|
||||||
instead of the syscalls implementation from libgloss.
|
instead of the syscalls implementation from libgloss.
|
||||||
*/
|
*/
|
||||||
void newlib_include_syscalls_impl(void)
|
void newlib_include_syscalls_impl(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-27
@@ -1,27 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#ifdef CONFIG_FREERTOS_UNICORE
|
#ifdef CONFIG_FREERTOS_UNICORE
|
||||||
#define CPU_NUM 1
|
#define CPU_NUM 1
|
||||||
#else
|
#else
|
||||||
#define CPU_NUM CONFIG_SOC_CPU_CORES_NUM
|
#define CPU_NUM CONFIG_SOC_CPU_CORES_NUM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long sysconf(int arg)
|
long sysconf(int arg)
|
||||||
{
|
{
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case _SC_NPROCESSORS_CONF:
|
case _SC_NPROCESSORS_CONF:
|
||||||
case _SC_NPROCESSORS_ONLN:
|
case _SC_NPROCESSORS_ONLN:
|
||||||
return CPU_NUM;
|
return CPU_NUM;
|
||||||
default:
|
default:
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user