lwip是否符合C语言编程规则,这些宏定义是怎么回事?(关于LwIP)

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include "sys_arch.h"

typedef void (* sys_timeout_handler)(void *arg);

struct sys_timeout {

struct sys_timeout *next;

u32_t time;

sys_timeout_handler h;

void *arg;

};

struct sys_timeouts {

struct sys_timeout *next;

};

/* sys_init() must be called before anthing else. */

void sys_init(void);

/*

* sys_timeout():

*

* Schedule a timeout a specified amount of milliseconds in the

* future. When the timeout occurs, the specified timeout handler will

* be called. The handler will be passed the "arg" argument when

* called.

*

*/

void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);

void sys_untimeout(sys_timeout_handler h, void *arg);

struct sys_timeouts *sys_arch_timeouts(void);

/* Semaphore functions. */

sys_sem_t sys_sem_new(u8_t count);

void sys_sem_signal(sys_sem_t sem);

//u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout);

u16_t sys_arch_sem_wait(sys_sem_t sem, u16_t timeout);

void sys_sem_free(sys_sem_t sem);

void sys_sem_wait(sys_sem_t sem);

int sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout);

/* Mailbox functions. */

sys_mbox_t sys_mbox_new(void);

void sys_mbox_post(sys_mbox_t mbox, void *msg);

//u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);

u16_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u16_t timeout);

void sys_mbox_free(sys_mbox_t mbox);

void sys_mbox_fetch(sys_mbox_t mbox, void **msg);

/* Critical Region Protection */

/* These functions must be implemented in the sys_arch.c file.

In some implementations they can provide a more light-weight protection

mechanism than using semaphores. Otherwise semaphores can be used for

implementation */

#ifndef SYS_ARCH_PROTECT

/** SYS_LIGHTWEIGHT_PROT

* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection

* for certain critical regions during buffer allocation, deallocation and memory

* allocation and deallocation.

*/

#if SYS_LIGHTWEIGHT_PROT

/** SYS_ARCH_DECL_PROTECT

* declare a protection variable. This macro will default to defining a variable of

* type sys_prot_t. If a particular port needs a different implementation, then

* this macro may be defined in sys_arch.h.

*/

#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev

/** SYS_ARCH_PROTECT

* Perform a "fast" protect. This could be implemented by

* disabling interrupts for an embedded system or by using a semaphore or

* mutex. The implementation should allow calling SYS_ARCH_PROTECT when

* already protected. The old protection level is returned in the variable

* "lev". This macro will default to calling the sys_arch_protect() function

* which should be implemented in sys_arch.c. If a particular port needs a

* different implementation, then this macro may be defined in sys_arch.h

*/

#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()

/** SYS_ARCH_UNPROTECT

* Perform a "fast" set of the protection level to "lev". This could be

* implemented by setting the interrupt level to "lev" within the MACRO or by

* using a semaphore or mutex. This macro will default to calling the

* sys_arch_unprotect() function which should be implemented in

* sys_arch.c. If a particular port needs a different implementation, then

* this macro may be defined in sys_arch.h

*/

#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)

sys_prot_t sys_arch_protect(void);

void sys_arch_unprotect(sys_prot_t pval);

#endif /* SYS_LIGHTWEIGHT_PROT */

#endif /* SYS_ARCH_PROTECT */

/* Thread functions. */

sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio);

/* The following functions are used only in Unix code, and

can be omitted when porting the stack. */

/* Returns the current time in microseconds. */

unsigned long sys_now(void);

#endif /* NO_SYS */

#endif /* __LWIP_SYS_H__ */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值