Skip to content

Commit

Permalink
Compatible with Raspberry pi
Browse files Browse the repository at this point in the history
  • Loading branch information
finaldie committed Oct 28, 2016
1 parent 636320c commit 8dc6997
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .Makefile.inc
Expand Up @@ -7,7 +7,7 @@ STD = -std=c99
WARN = -Wall
EXTRA = -pedantic -Wpadded -Werror -Wextra -Wno-unused-parameter
EXTRA += -Wno-unused-function -Wfloat-equal -Winline -Wdisabled-optimization
EXTRA += -Wconversion
EXTRA += -Wconversion -fno-omit-frame-pointer
OTHER = -pipe -g -ggdb3
CC_SHARED = -fPIC
#MACRO = -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE
Expand Down
3 changes: 3 additions & 0 deletions .Makefile.tests
Expand Up @@ -16,3 +16,6 @@ VALGRIND_FCO = valgrind --tool=memcheck -v --leak-check=full \
--suppressions=./tests/valgrind/fco.suppression \
--gen-suppressions=all --error-exitcode=1

VALGRIND_FEV = valgrind --tool=memcheck -v --leak-check=full \
--suppressions=./tests/valgrind/fev.suppression \
--gen-suppressions=all --error-exitcode=1
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -49,7 +49,7 @@ valgrind-check: $(TEST_TARGET)
@$(VALGRIND) ./tests/test_fcache
@$(VALGRIND) ./tests/test_ftime
@$(VALGRIND_FCO) ./tests/test_fco
@$(VALGRIND) ./tests/test_fev
@$(VALGRIND_FEV) ./tests/test_fev

clean: clean-flist clean-fcache clean-fhash clean-fmbuf clean-fco clean-fnet
clean: clean-ftime clean-flock clean-fthpool clean-fconf clean-flog clean-fev
Expand Down
5 changes: 5 additions & 0 deletions fco/fco.c
Expand Up @@ -23,6 +23,11 @@ typedef struct plugin_meta {

struct _fco {
ucontext_t ctx;

#if __WORDSIZE == 32
int _padding;
#endif

ucontext_t* prev_ctx;
fco_sched* root;
fco_sched* owner;
Expand Down
23 changes: 10 additions & 13 deletions fev/fev_conn.c
Expand Up @@ -12,14 +12,11 @@
#define FEV_CONN_TIME_SERVICE_INTERVAL 1

typedef struct fev_conn_info {
int fd;
#if __WORDSIZE == 64
int padding;
#endif

ftimer_node* timer;
fev_conn_cb conn_cb;
conn_arg_t arg;
ftimer_node* timer;
fev_conn_cb conn_cb;
int fd;
int _padding;
fev_conn_arg_t arg;
} fev_conn_info;

static
Expand Down Expand Up @@ -70,11 +67,11 @@ void on_timer(fev_state* fev, void* arg)
}

int fev_conn(fev_state* fev,
const char* ip,
in_port_t port,
int timeout, /* unit ms */
fev_conn_cb pfunc,
conn_arg_t arg)
const char* ip,
in_port_t port,
int timeout, /* unit ms */
fev_conn_cb pfunc,
fev_conn_arg_t arg)
{
int sockfd = -1;
int s = fnet_conn_async(ip, port, &sockfd);
Expand Down
1 change: 1 addition & 0 deletions fev/fev_epoll.c
Expand Up @@ -7,6 +7,7 @@

typedef struct state {
int epfd;
int _padding;
struct epoll_event events[1];
} state;

Expand Down
2 changes: 1 addition & 1 deletion fhash/fhash_core.c
Expand Up @@ -6,7 +6,7 @@

#include "flibs/fhash_core.h"

typedef uint64_t data_sz_t;
typedef size_t data_sz_t;

#define DEFAULT_TABLE_SIZE 10
#define DEFAULT_LIST_SIZE 4
Expand Down
1 change: 1 addition & 0 deletions flog/flog.c
Expand Up @@ -347,6 +347,7 @@ thread_data_t* _log_create_thread_data()
th_data->efd = efd;

struct epoll_event ee;
memset(&ee, 0, sizeof(ee));
ee.data.u64 = 0;
ee.data.fd = 0;
ee.data.ptr = th_data;
Expand Down
10 changes: 4 additions & 6 deletions fthread_pool/fthread_pool.c
Expand Up @@ -17,13 +17,11 @@ typedef enum {

typedef struct {
flock_cond_t cond;
fmbuf* pbuf;
void* parg;
int tid;
fmbuf* pbuf;
void* parg;
int tid;

#if __WORDSIZE == 64
int padding;
#endif
int _padding;
} thread_data;

#pragma pack(4)
Expand Down
18 changes: 9 additions & 9 deletions include/flibs/fev_conn.h
Expand Up @@ -9,29 +9,29 @@ extern "C" {
#include <netinet/in.h>
#include <flibs/fev.h>

typedef union conn_arg_t {
int u32;
typedef union fev_conn_arg_t {
uint32_t u32;
uint64_t u64;
void* ptr;
}conn_arg_t;
} fev_conn_arg_t;

// should call fev_conn() after this
int fev_conn_module_init(fev_state*);

// fd > 0 : sucess
// fd == -1 : error or timeout
typedef void (*fev_conn_cb)(int fd, conn_arg_t arg);
typedef void (*fev_conn_cb)(int fd, fev_conn_arg_t arg);

// asynchronous connect method used fev
// unit of timeout : ms
// return 0: connect sucessful or inprocess, you need to wait for callback
// return -1: connect error, there is no need to wait for callback, it won't be called
int fev_conn(fev_state*,
const char* ip,
in_port_t port,
int timeout,
fev_conn_cb,
conn_arg_t);
const char* ip,
in_port_t port,
int timeout,
fev_conn_cb,
fev_conn_arg_t);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion include/flibs/fhash_core.h
Expand Up @@ -13,7 +13,7 @@ extern "C" {
#define FHASH_MASK_AUTO_REHASH 0x1

typedef int32_t key_sz_t;
typedef int64_t value_sz_t;
typedef size_t value_sz_t;

typedef struct fhash fhash;

Expand Down
8 changes: 6 additions & 2 deletions include/flibs/fhash_uint64.h
Expand Up @@ -12,8 +12,12 @@ typedef struct {
fhash_iter iter;

// read only
uint64_t key;
void* value;
uint64_t key;
void* value;

#if __WORDSIZE == 32
int _padding;
#endif
} fhash_u64_iter;

/**
Expand Down
5 changes: 5 additions & 0 deletions include/flibs/flock.h
Expand Up @@ -9,6 +9,11 @@ extern "C" {

typedef struct flock_cond_t {
unsigned long _count;

#if __WORDSIZE == 32
int _padding;
#endif

pthread_mutex_t _mutex;
pthread_cond_t _cond;
} flock_cond_t;
Expand Down
15 changes: 2 additions & 13 deletions tests/t_fev.c
Expand Up @@ -46,17 +46,6 @@ typedef struct fake_fev_state{
int reserved; // unused
} fake_fev_state;

typedef struct fake_fev_conn_info {
int fd;
#if __WORDSIZE == 64
int padding;
#endif

fev_timer* timer;
fev_conn_cb conn_cb;
conn_arg_t arg;
} fake_fev_conn_info;

void _test_fev_read(fev_state* fev, int fd, int mask, void* arg)
{
(void)mask;
Expand Down Expand Up @@ -333,7 +322,7 @@ static void fake_accept1(fev_state* fev, int fd, void* ud)
//close(fd);
}

static void _test_for_conn(int fd, conn_arg_t arg)
static void _test_for_conn(int fd, fev_conn_arg_t arg)
{
(void)arg;
//printf("tid=%lu, in async connection callback, time=%ld\n", pthread_self(), time(NULL));
Expand All @@ -359,7 +348,7 @@ static void* fake_listener1(void* arg)
//printf("wait for poll\n");
start = 1;

conn_arg_t carg;
fev_conn_arg_t carg;
//printf("before start async conn, time=%ld\n", time(NULL));
int ret = fev_conn(g_fev, "127.0.0.1", 17759, 5000, _test_for_conn, carg);
FCUNIT_ASSERT(0 == ret);
Expand Down
2 changes: 1 addition & 1 deletion tests/t_hash.c
Expand Up @@ -9,7 +9,7 @@
#include "flibs/fhash_int.h"

//=====================FAKE STRUCTURE===========================================
typedef uint64_t data_sz_t;
typedef size_t data_sz_t;

typedef struct _fhash_node {
data_sz_t real_sz; // size of real memory space
Expand Down
82 changes: 82 additions & 0 deletions tests/valgrind/fco.suppression
Expand Up @@ -396,3 +396,85 @@
fun:co_main
obj:*
}

########## Raspberry Pi ############
{
<fco_resume jump condition>
Memcheck:Cond
fun:__startcontext
fun:fco_resume
fun:test_fco
fun:main
}

{
<_fco_call_plugin: Use of uninitialised value of size 4>
Memcheck:Value4
fun:_fco_call_plugin
fun:fco_resume
fun:test
fun:co_main
obj:*
}

{
<__startcontext: Use of uninitialised value of size 4>
Memcheck:Value4
fun:__startcontext
fun:fco_resume
fun:test_fco
fun:main
}

{
<libc: Use of uninitialised value of size 4>
Memcheck:Value4
obj:*
fun:fco_resume
fun:test_fco
fun:main
}

{
<sigprocmask: Conditional jump on uninitialised value>
Memcheck:Cond
fun:sigprocmask
obj:*
}

{
<sigprocmask: Use of uninitialised value of size 4>
Memcheck:Value4
fun:sigprocmask
obj:*
}

{
<Syscall param rt_sigprocmask(set) contains uninitialised byte(s)>
Memcheck:Param
rt_sigprocmask(set)
fun:sigprocmask
obj:*
}

{
<libc: Invalid read of size 4>
Memcheck:Addr4
obj:/lib/arm-linux-gnueabihf/libc-2.13.so
obj:*
}

{
<libc: Use of uninitialised value of size 4>
Memcheck:Value4
obj:/lib/arm-linux-gnueabihf/libc-2.13.so
obj:*
}

{
<fco_resume: Conditional jump on uninitialised value>
Memcheck:Cond
fun:fco_resume
fun:test_fco
fun:main
}
8 changes: 8 additions & 0 deletions tests/valgrind/fev.suppression
@@ -0,0 +1,8 @@
########## Raspberry PI ##########
{
<Syscall param epoll_ctl(event) points to uninitialised byte(s)>
Memcheck:Param
epoll_ctl(event)
fun:epoll_ctl
}

0 comments on commit 8dc6997

Please sign in to comment.