-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
310 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## libuio | ||
This is a simple libuio library. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2014-2020 Zhifeng Gong <gozfree@163.com> | ||
* | ||
* 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 <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int uio_open(struct uio_info_t* info) | ||
{ | ||
return 0; | ||
} | ||
|
||
void uio_close(struct uio_info_t* info) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2014-2020 Zhifeng Gong <gozfree@163.com> | ||
* | ||
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2014-2020 Zhifeng Gong <gozfree@163.com> | ||
* | ||
* 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 <sys/stat.h> | ||
|
||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2014-2020 Zhifeng Gong <gozfree@163.com> | ||
* | ||
* 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 <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <<! | ||
/* Automatically generated by version.sh - do not modify! */ | ||
#ifndef ${LIBNAME}_VERSION_H | ||
#define ${LIBNAME}_VERSION_H | ||
#define ${libname}_version ${version} | ||
#define ${libname}_buildid ${buildid} | ||
#endif | ||
! | ||
} | ||
|
||
autogen_version_h |