diff --git a/libuio/Android.mk b/libuio/Android.mk new file mode 100644 index 00000000..19cd27aa --- /dev/null +++ b/libuio/Android.mk @@ -0,0 +1,14 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := libuio + +LIBRARIES_DIR := $(LOCAL_PATH)/../ + +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +# Add your application source files here... +LOCAL_SRC_FILES := libuio.c + +include $(BUILD_SHARED_LIBRARY) diff --git a/libuio/Makefile b/libuio/Makefile new file mode 100644 index 00000000..797bd9eb --- /dev/null +++ b/libuio/Makefile @@ -0,0 +1,104 @@ +############################################################################### +# common +############################################################################### +#ARCH: linux/pi/android/ios/ +ARCH ?= linux +CROSS_PREFIX ?= +OUTPUT ?= /usr/local +BUILD_DIR := $(shell pwd)/../build/ +ARCH_INC := $(BUILD_DIR)/$(ARCH).inc +COLOR_INC := $(BUILD_DIR)/color.inc + +ifeq ($(ARCH_INC), $(wildcard $(ARCH_INC))) +include $(ARCH_INC) +endif + +CC = $(CROSS_PREFIX)gcc +CXX = $(CROSS_PREFIX)g++ +LD = $(CROSS_PREFIX)ld +AR = $(CROSS_PREFIX)ar + +ifeq ($(COLOR_INC), $(wildcard $(COLOR_INC))) +include $(COLOR_INC) +else +CC_V = $(CC) +CXX_V = $(CXX) +LD_V = $(LD) +AR_V = $(AR) +CP_V = $(CP) +RM_V = $(RM) +endif + +############################################################################### +# target and object +############################################################################### +LIBNAME = libuio +VERSION_SH = $(shell pwd)/version.sh $(LIBNAME) +VER = $(shell $(VERSION_SH); awk '/define\ $(LIBNAME)_version/{print $$3}' version.h) +TGT_LIB_H = $(LIBNAME).h +TGT_LIB_A = $(LIBNAME).a +TGT_LIB_SO = $(LIBNAME).so +TGT_LIB_SO_VER = $(TGT_LIB_SO).${VER} +TGT_UNIT_TEST = test_$(LIBNAME) + +OBJS_LIB = $(LIBNAME).o +OBJS_UNIT_TEST = test_$(LIBNAME).o + +############################################################################### +# cflags and ldflags +############################################################################### +CFLAGS := -g -Wall -Werror -fPIC +CFLAGS += $($(ARCH)_CFLAGS) +CFLAGS += -I$(OUTPUT)/include + +SHARED := -shared + +LDFLAGS := $($(ARCH)_LDFLAGS) +LDFLAGS += -pthread + +############################################################################### +# target +############################################################################### +.PHONY : all clean + +TGT := $(TGT_LIB_A) +TGT += $(TGT_LIB_SO) +TGT += $(TGT_UNIT_TEST) + +OBJS := $(OBJS_LIB) $(OBJS_UNIT_TEST) + +all: $(TGT) + +%.o:%.c + $(CC_V) -c $(CFLAGS) $< -o $@ + +$(TGT_LIB_A): $(OBJS_LIB) + $(AR_V) rcs $@ $^ + +$(TGT_LIB_SO): $(OBJS_LIB) + $(CC_V) -o $@ $^ $(SHARED) + @mv $(TGT_LIB_SO) $(TGT_LIB_SO_VER) + @ln -sf $(TGT_LIB_SO_VER) $(TGT_LIB_SO) + +$(TGT_UNIT_TEST): $(OBJS_UNIT_TEST) $(ANDROID_MAIN_OBJ) + $(CC_V) -o $@ $^ $(TGT_LIB_A) $(LDFLAGS) + +clean: + $(RM_V) -f $(OBJS) + $(RM_V) -f $(TGT) + $(RM_V) -f version.h + $(RM_V) -f $(TGT_LIB_SO)* + $(RM_V) -f $(TGT_LIB_SO_VER) + +install: + $(MAKEDIR_OUTPUT) + $(CP_V) -r $(TGT_LIB_H) $(OUTPUT)/include + $(CP_V) -r $(TGT_LIB_A) $(OUTPUT)/lib + $(CP_V) -r $(TGT_LIB_SO) $(OUTPUT)/lib + $(CP_V) -r $(TGT_LIB_SO_VER) $(OUTPUT)/lib + +uninstall: + $(RM_V) -f $(OUTPUT)/include/$(TGT_LIB_H) + $(RM_V) -f $(OUTPUT)/lib/$(TGT_LIB_A) + $(RM_V) -f $(OUTPUT)/lib/$(TGT_LIB_SO) + $(RM_V) -f $(OUTPUT)/lib/$(TGT_LIB_SO_VER) diff --git a/libuio/README.md b/libuio/README.md new file mode 100644 index 00000000..458a01a0 --- /dev/null +++ b/libuio/README.md @@ -0,0 +1,3 @@ +## libuio +This is a simple libuio library. + diff --git a/libuio/libuio.c b/libuio/libuio.c new file mode 100644 index 00000000..51d3e874 --- /dev/null +++ b/libuio/libuio.c @@ -0,0 +1,35 @@ +/****************************************************************************** + * Copyright (C) 2014-2020 Zhifeng Gong + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ +#include "libuio_internal.h" +#include "libuio.h" +#include +#include + +int uio_open(struct uio_info_t* info) +{ + return 0; +} + +void uio_close(struct uio_info_t* info) +{ + +} diff --git a/libuio/libuio.h b/libuio/libuio.h new file mode 100644 index 00000000..9ec573f4 --- /dev/null +++ b/libuio/libuio.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * Copyright (C) 2014-2020 Zhifeng Gong + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ +#ifndef LIBUIO_H +#define LIBUIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct uio_info_t; + +int uio_open(struct uio_info_t* info); +void uio_close(struct uio_info_t* info); + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libuio/libuio_internal.h b/libuio/libuio_internal.h new file mode 100644 index 00000000..296e13db --- /dev/null +++ b/libuio/libuio_internal.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * Copyright (C) 2014-2020 Zhifeng Gong + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ +#ifndef LIBUIO_INTERNAL_H +#define LIBUIO_INTERNAL_H + +#include "libuio.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct uio_map_t { + unsigned long addr; + size_t size; + size_t offset; + char *name; + void *map; +}; + +struct uio_info_t { + char *path; + char *name; + char *version; + struct uio_map_t *maps; + char *devname; + dev_t devid; + int maxmap; + int fd; +}; + + +int uio_open (struct uio_info_t* info); + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libuio/test_libuio.c b/libuio/test_libuio.c new file mode 100644 index 00000000..f46b1a44 --- /dev/null +++ b/libuio/test_libuio.c @@ -0,0 +1,29 @@ +/****************************************************************************** + * Copyright (C) 2014-2020 Zhifeng Gong + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ +#include "libuio.h" +#include +#include + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/libuio/version.sh b/libuio/version.sh new file mode 100755 index 00000000..e4d37fd8 --- /dev/null +++ b/libuio/version.sh @@ -0,0 +1,27 @@ +#!/bin/sh +major=0 +minor=1 +patch=0 + +libname=$1 +output=version.h + +LIBNAME=`echo ${libname} | tr 'a-z' 'A-Z'` +export version=${major}.${minor}.${patch} +export buildid=`git log -1 --pretty=format:"git-%cd-%h" --date=short .` +autogen_version_h() +{ +cat > version.h <