Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: chunkio: upgrade to v1.3.0 #6027

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmake/headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ include_directories(
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CO}
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RBTREE}
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MSGPACK}/include

# Chunk I/O generate headers also in the binary path
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CHUNKIO}/include
${CMAKE_CURRENT_BINARY_DIR}/lib/chunkio/include

${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}/src
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include/monkey
Expand Down
13 changes: 9 additions & 4 deletions lib/chunkio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
project(chunk-io)

set(CIO_VERSION_MAJOR 1)
set(CIO_VERSION_MINOR 2)
set(CIO_VERSION_MINOR 3)
set(CIO_VERSION_PATCH 0)
set(CIO_VERSION_STR "${CIO_VERSION_MAJOR}.${CIO_VERSION_MINOR}.${CIO_VERSION_PATCH}")

Expand All @@ -14,7 +14,12 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall ")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__=__FILE__")
# Set __FILENAME__
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__=__FILE__")
endif()

include(cmake/macros.cmake)

Expand Down Expand Up @@ -88,12 +93,12 @@ endif()

configure_file(
"${PROJECT_SOURCE_DIR}/include/chunkio/cio_info.h.in"
"${PROJECT_SOURCE_DIR}/include/chunkio/cio_info.h"
"${PROJECT_BINARY_DIR}/include/chunkio/cio_info.h"
)

configure_file(
"${PROJECT_SOURCE_DIR}/include/chunkio/cio_version.h.in"
"${PROJECT_SOURCE_DIR}/include/chunkio/cio_version.h"
"${PROJECT_BINARY_DIR}/include/chunkio/cio_version.h"
)

include_directories(
Expand Down
2 changes: 1 addition & 1 deletion lib/chunkio/deps/crc32/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ crc_t crc_update(crc_t crc, const void *data, size_t data_len)
const uint32_t *d32 = (const uint32_t *)d;
while (data_len >= 8)
{
#if __BYTE_ORDER == __BIG_ENDIAN
#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
crc_t d1 = *d32++ ^ le16toh(crc);
crc_t d2 = *d32++;
crc =
Expand Down
4 changes: 3 additions & 1 deletion lib/chunkio/include/chunkio/chunkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@
/* defaults */
#define CIO_MAX_CHUNKS_UP 64 /* default limit for cio_ctx->max_chunks_up */

struct cio_ctx;

struct cio_options {
int flags;
char *root_path;

/* logging */
int log_level;
void (*log_cb)(void *, int, const char *, int, const char *);
int (*log_cb)(struct cio_ctx *, int, const char *, int, char *);

char *user;
char *group;
Expand Down
11 changes: 7 additions & 4 deletions lib/chunkio/include/chunkio/cio_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ struct cio_file {
char *path; /* root path + stream */
char *map; /* map of data */
#ifdef _WIN32
void *h;
crc_t crc_be;
int map_synced;
HANDLE backing_file;
HANDLE backing_mapping;
#endif
/* cached addr */
char *st_content;
Expand All @@ -61,7 +60,7 @@ void cio_file_close(struct cio_chunk *ch, int delete);
int cio_file_write(struct cio_chunk *ch, const void *buf, size_t count);
int cio_file_write_metadata(struct cio_chunk *ch, char *buf, size_t size);
int cio_file_sync(struct cio_chunk *ch);
int cio_file_fs_size_change(struct cio_file *cf, size_t new_size);
int cio_file_resize(struct cio_file *cf, size_t new_size);
char *cio_file_hash(struct cio_file *cf);
void cio_file_hash_print(struct cio_file *cf);
void cio_file_calculate_checksum(struct cio_file *cf, crc_t *out);
Expand All @@ -77,5 +76,9 @@ int cio_file_up(struct cio_chunk *ch);
int cio_file_up_force(struct cio_chunk *ch);
int cio_file_lookup_user(char *user, void **result);
int cio_file_lookup_group(char *group, void **result);
int cio_file_update_size(struct cio_file *cf);

#define cio_file_report_runtime_error() { cio_file_native_report_runtime_error(); }
#define cio_file_report_os_error() { cio_file_native_report_os_error(); }

#endif
55 changes: 55 additions & 0 deletions lib/chunkio/include/chunkio/cio_file_native.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* Chunk I/O
* =========
* Copyright 2018 Eduardo Silva <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef CIO_FILE_NATIVE_H
#define CIO_FILE_NATIVE_H

#include <chunkio/cio_file.h>



#ifdef _WIN32
#define cio_file_native_is_open(cf) (cf->backing_file != INVALID_HANDLE_VALUE)
#define cio_file_native_is_mapped(cf) (cf->backing_mapping != INVALID_HANDLE_VALUE)
#define cio_file_native_report_runtime_error() { cio_errno(); }
#define cio_file_native_report_os_error() { cio_winapi_error(); }
#else
#define cio_file_native_is_open(cf) (cf->fd != -1)
#define cio_file_native_is_mapped(cf) (cf->map != NULL)
#define cio_file_native_report_runtime_error() { cio_errno(); }
#define cio_file_native_report_os_error() { cio_errno(); }
#endif

int cio_file_native_apply_acl_and_settings(struct cio_ctx *ctx, struct cio_file *cf);
char *cio_file_native_compose_path(char *root_path, char *stream_name,
char *chunk_name);
int cio_file_native_unmap(struct cio_file *cf);
int cio_file_native_map(struct cio_file *cf, size_t map_size);
int cio_file_native_remap(struct cio_file *cf, size_t new_size);
int cio_file_native_lookup_user(char *user, void **result);
int cio_file_native_lookup_group(char *group, void **result);
int cio_file_native_get_size(struct cio_file *cf, size_t *file_size);
int cio_file_native_filename_check(char *name);
int cio_file_native_open(struct cio_file *cf);
int cio_file_native_close(struct cio_file *cf);
int cio_file_native_delete(struct cio_file *cf);
int cio_file_native_sync(struct cio_file *cf, int sync_mode);
int cio_file_native_resize(struct cio_file *cf, size_t new_size);

#endif
4 changes: 2 additions & 2 deletions lib/chunkio/include/chunkio/cio_file_st.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ static inline uint16_t cio_file_st_get_meta_len(char *map)
/* Set metadata length */
static inline void cio_file_st_set_meta_len(char *map, uint16_t len)
{
map[22] = (uint8_t) len >> 8;
map[23] = (uint8_t) len;
map[22] = (uint8_t) (len >> 8);
map[23] = (uint8_t) (len & 0xFF);
}

/* Return pointer to start point of metadata */
Expand Down
3 changes: 2 additions & 1 deletion lib/chunkio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(src
cio_os.c
cio_log.c
cio_file.c
cio_memfs.c
cio_chunk.c
cio_meta.c
Expand All @@ -27,7 +28,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
else()
set(src
${src}
cio_file.c
cio_file_unix.c
)
endif()

Expand Down
Loading