Skip to content

Commit

Permalink
migrate to Android platform OK!
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Feb 12, 2017
1 parent 5e1bd3c commit 09e4b0d
Show file tree
Hide file tree
Showing 46 changed files with 695 additions and 66 deletions.
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
cmake_minimum_required(VERSION 2.8)
project(acl)
message(${CMAKE_SYSTEM_NAME})

#set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")
add_subdirectory(lib_protocol/src lib_protocol)
add_subdirectory(lib_acl/src lib_acl)
add_subdirectory(lib_acl_cpp/src lib_acl_cpp)
if (CMAKE_SYSTEM_NAME MATCHES "Linuxxx")
add_subdirectory(lib_fiber/src lib_fiber)
#set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")

if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
message(FATAL_ERROR "Please into another dir to build!")
endif()

add_subdirectory(lib_acl lib_acl)
add_subdirectory(lib_protocol lib_protocol)
add_subdirectory(lib_acl_cpp lib_acl_cpp)

#if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Android")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_subdirectory(lib_fiber/c lib_fiber)
add_subdirectory(lib_fiber/cpp lib_fiber_cpp)
endif()
1 change: 1 addition & 0 deletions build/.keepme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keepme
114 changes: 114 additions & 0 deletions lib_acl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
cmake_minimum_required(VERSION 2.8)

#set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")

#message(project_dir=${PROJECT_SOURCE_DIR})

if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
message(FATAL_ERROR "Please into another dir to build!")
endif()

add_definitions(
"-W"
"-Wall"
"-Werror"
"-Wshadow"
"-Wpointer-arith"
"-Waggregate-return"
"-Wmissing-prototypes"
"-D_REENTRANT"
"-D_USE_FAST_MACRO"
"-DACL_WRITEABLE_CHECK"
"-Wno-long-long"
"-Wuninitialized"
"-D_POSIX_PTHREAD_SEMANTICS"
"-DACL_PREPARE_COMPILE"
"-Wno-invalid-source-encoding"
"-fPIC"
"-Wstrict-prototypes"
)

if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "DEBUG")
else()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
endif()

if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
add_definitions("-O3")
else()
add_definitions("-g")
endif()

string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
add_definitions("-DANDROID")
elseif(CMAKE_SYSTEM_NAME MATCHES "LINUX")
else()
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
endif()

##############################################################################

set(src ${CMAKE_CURRENT_SOURCE_DIR}/src)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
)

set(sources
${src}/stdlib
${src}/stdlib/debug
${src}/stdlib/memory
${src}/stdlib/filedir
${src}/stdlib/string
${src}/stdlib/common
${src}/stdlib/sys
${src}/stdlib/sys/unix
${src}/stdlib/configure
${src}/stdlib/iostuff
${src}/aio
${src}/code
${src}/db
${src}/db/memdb
${src}/db/mysql
${src}/db/null
${src}/db/zdb
${src}/event
${src}/init
${src}/ioctl
${src}/json
${src}/master
${src}/master/framework
${src}/master/framework/trigger
${src}/master/template
${src}/msg
${src}/net
${src}/net/dns
${src}/net/connect
${src}/net/listen
${src}/private
${src}/thread
${src}/unit_test
${src}/xml
)

foreach(iter ${sources})
aux_source_directory(${iter} lib_src)
endforeach()

if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)

set(LIBRARY_OUTPUT_PATH ${lib_output_path})
add_library(_acl_static STATIC ${lib_src})
SET_TARGET_PROPERTIES(_acl_static PROPERTIES OUTPUT_NAME "_acl")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
endif()

add_library(_acl SHARED ${lib_src})

##############################################################################
3 changes: 2 additions & 1 deletion lib_acl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ endif

# For Linux
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
CFLAGS += -DLINUX2 -fPIC -Werror
# CFLAGS += -DLINUX2 -fPIC -Werror
CFLAGS += -fPIC -Werror
UNIXTYPE = LINUX
ifeq ($(findstring i686, $(OSTYPE)), i686)
CFLAGS += -march=i686
Expand Down
8 changes: 8 additions & 0 deletions lib_acl/changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
�޸���ʷ�б���

575) 2017.1.31
575.1) compile: �� Linux/Android ƽ̨�±���ʱ����ͷ�ļ��Զ�ʶ�����ϵͳ���ͣ�
������ Makefile �ļ���ר��ָ��

574) 2017.1.28--1.29
574.1) bugfix: acl_dbuf_pool.c ֧�� ARM LINUX���ڲ��ڷ����ڴ�Ƭʱ��Ӧ���� 4
�ֽڶ���

573) 2016.12.29
573.1) bugfix: acl_slice.c ���޸��� SLICE1 ��ʽ�����ڴ��һ�� BUG

Expand Down
16 changes: 10 additions & 6 deletions lib_acl/include/stdlib/acl_define_linux.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#ifndef ACL_DEFINE_LINUX_INCLUDE_H
#define ACL_DEFINE_LINUX_INCLUDE_H

#ifdef ACL_ARM_LINUX
# ifndef LINUX2
# define LINUX2
#if defined(ANDROID)
# ifndef ACL_ANDROID
# define ACL_ANDROID
# endif
#endif

#ifdef LINUX2
# define ACL_LINUX
# define ACL_UNIX
#if defined(LINUX2) || defined(ACL_ANDROID) || defined(__linux__)
# ifndef ACL_LINUX
# define ACL_LINUX
# endif
# ifndef ACL_UNIX
# define ACL_UNIX
# endif

#include <stddef.h> /* just for size_t */

Expand Down
2 changes: 1 addition & 1 deletion lib_acl/samples/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ endif

#Path for Linux
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
CFLAGS += -DLINUX2
# CFLAGS += -DLINUX2
SYSLIB += -lcrypt -rdynamic
endif

Expand Down
3 changes: 2 additions & 1 deletion lib_acl/samples/Makefile_cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ endif

#Path for Linux
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
CFLAGS += -DLINUX2 -pedantic
# CFLAGS += -DLINUX2 -pedantic
CFLAGS += -pedantic
SYSLIB += -lcrypt
endif

Expand Down
2 changes: 1 addition & 1 deletion lib_acl/src/event/events_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {
# define ACL_EVENTS_STYLE_WMSG 6
#endif

#if defined(LINUX2) && !defined(MINGW)
#if defined(ACL_LINUX) && !defined(MINGW)
# define ACL_EVENTS_KERNEL_STYLE ACL_EVENTS_STYLE_EPOLL
#elif defined(SUNOS5)
# define ACL_EVENTS_KERNEL_STYLE ACL_EVENTS_STYLE_DEVPOLL
Expand Down
4 changes: 2 additions & 2 deletions lib_acl/src/net/dns/acl_netdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ ACL_DNS_DB *acl_gethostbyname(const char *name, int *h_error)

#elif defined(ACL_UNIX)
memset(&h_buf, 0, sizeof(h_buf));
# if defined(LINUX2) || defined(ACL_FREEBSD)
# if defined(ACL_LINUX) || defined(ACL_FREEBSD)
n = gethostbyname_r(name, &h_buf, buf, sizeof(buf), &h_addrp, &errnum);
if (n) {
if (h_error)
Expand Down Expand Up @@ -473,7 +473,7 @@ typedef struct ACL_DNS_ERROR {
} ACL_DNS_ERROR;

static ACL_DNS_ERROR __dns_errlist[] = {
#ifdef LINUX2
#ifdef ACL_LINUX
{ HOST_NOT_FOUND, "The specified host is unknown" },
{ TRY_AGAIN, "A temporary error occurred on an authoritative name server. Try again later." },
{ NO_RECOVERY, "A non-recoverable name server error occurred" },
Expand Down
6 changes: 3 additions & 3 deletions lib_acl/src/stdlib/acl_mylog.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int open_file_log(const char *filename, const char *logpre)
#else
int flag = O_RDWR | O_CREAT | O_APPEND;
#endif
#ifdef ACL_ARM_LINUX
#ifdef ACL_ANDROID
int mode = 0644;
#else
int mode = S_IREAD | S_IWRITE;
Expand Down Expand Up @@ -580,7 +580,7 @@ static void file_vsyslog(ACL_LOG *log, const char *info, const char *fmt, va_lis
snprintf(tbuf, sizeof(tbuf), "%s %s (pid=%d, tid=%u)(%s): ",
fmtstr, log->logpre, (int) getpid(),
(unsigned int) acl_pthread_self(), info);
#elif defined(LINUX2)
#elif defined(ACL_LINUX)
snprintf(tbuf, sizeof(tbuf), "%s %s (pid=%d, tid=%llu)(%s): ",
fmtstr, log->logpre, (int) getpid(),
(unsigned long long int) acl_pthread_self(), info);
Expand Down Expand Up @@ -637,7 +637,7 @@ static void net_vsyslog(ACL_LOG *log, const char *info, const char *fmt, va_list
snprintf(tbuf, sizeof(tbuf), " %s (pid=%d, tid=%u)(%s): ",
log->logpre, (int) getpid(),
(unsigned int) acl_pthread_self(), info);
#elif defined(LINUX2)
#elif defined(ACL_LINUX)
snprintf(tbuf, sizeof(tbuf), " %s (pid=%d, tid=%llu)(%s): ",
log->logpre, (int) getpid(),
(unsigned long long int) acl_pthread_self(), info);
Expand Down
2 changes: 1 addition & 1 deletion lib_acl/src/stdlib/acl_vstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ char *acl_vstream_loadfile2(const char *path, ssize_t *size)
#else
int oflags = O_RDONLY;
#endif
#ifdef ACL_ARM_LINUX
#ifdef ACL_ANDROID
int mode = 0644;
#else
int mode = S_IREAD;
Expand Down
2 changes: 1 addition & 1 deletion lib_acl/src/stdlib/common/acl_iplink.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static char *__sane_inet_ntoa(unsigned int src, char *dst, size_t size)
/* in.s_addr = ntohl(src); */
in.s_addr = src;
bytes = (unsigned char *) &in;
#ifdef LINUX2
#ifdef ACL_LINUX
snprintf (dst, 18, "%d.%d.%d.%d", bytes[3], bytes[2], bytes[1], bytes[0]);
#elif defined(SUNOS5)
snprintf (dst, 18, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3]);
Expand Down
5 changes: 1 addition & 4 deletions lib_acl/src/stdlib/common/avl.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,8 @@ avl_create(avl_tree_t *tree, int (*compar) (const void *, const void *),
*/
/* ARGSUSED */
void
avl_destroy(avl_tree_t *tree)
avl_destroy(avl_tree_t *tree acl_unused)
{
#ifdef ACL_ARM_LINUX
(void) tree;
#endif
ASSERT(tree);
ASSERT(tree->avl_numnodes == 0);
ASSERT(tree->avl_root == NULL);
Expand Down
4 changes: 2 additions & 2 deletions lib_acl/src/stdlib/configure/acl_loadcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ ACL_CFG_PARSER *acl_cfg_parser_load(const char *pathname, const char *delimiter)
}

#ifdef ACL_UNIX
# ifdef ACL_ARM_LINUX
# ifdef ACL_ANDROID
filefd = acl_file_open(pathname, O_RDWR, 0644);
# else
filefd = acl_file_open(pathname, O_RDWR, S_IREAD | S_IWRITE | S_IRGRP);
Expand Down Expand Up @@ -565,7 +565,7 @@ int acl_cfg_parser_dump(const ACL_CFG_PARSER *parser,
if (parser == NULL || pathname == NULL || *pathname == 0)
return (-1);
#ifdef ACL_UNIX
# ifdef ACL_ARM_LINUX
# ifdef ACL_ANDROID
filefd = acl_file_open(pathname,
O_CREAT | O_TRUNC | O_APPEND | O_WRONLY, 0644);
# else
Expand Down
4 changes: 2 additions & 2 deletions lib_acl/src/stdlib/iostuff/acl_open_limit.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <stdio.h>

#ifdef ACL_ARM_LINUX
#ifdef ACL_ANDROID
int acl_open_limit(int limit)
{
/* xxx: just limit to 1024 */
Expand Down Expand Up @@ -99,6 +99,6 @@ int acl_open_limit(int limit)
#endif
}

#endif /* !ACL_ARM_LINUX */
#endif /* !ACL_ANDROID */
#endif /* !ACL_UNIX */

2 changes: 1 addition & 1 deletion lib_acl/src/stdlib/iostuff/acl_read_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "stdlib/acl_iostuff.h"
#include "../../init/init.h"

#if defined(LINUX2) && !defined(MINGW) && defined(USE_EPOLL)
#if defined(ACL_LINUX) && !defined(MINGW) && defined(USE_EPOLL)

#include "init/acl_init.h"
#include "thread/acl_pthread.h"
Expand Down
2 changes: 1 addition & 1 deletion lib_acl/src/stdlib/memory/acl_dbuf_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void *acl_dbuf_pool_alloc(ACL_DBUF_POOL *pool, size_t length)
void *ptr;
ACL_DBUF *dbuf;

length += length % 4;
length += 4 - length % 4;

if (length > pool->block_size)
dbuf = acl_dbuf_alloc(pool, length);
Expand Down
Loading

0 comments on commit 09e4b0d

Please sign in to comment.