libev 宏展开

想看源码,宏太多,看着累,宏展开,再看,功力时间不够,先放下

放上宏展开后的代码。

libev4.20

展开方示为

./configure

修改makefile文件,字符串 替换CC为 CPP

注意要把基础的CC定义保留

make

mv ev.o ev.c

mv event.o event.c

make clean

 

修改makefile文件,字符串替换CPP-》CC

注意要把基础的CPP定义保留 

 

宏展开后#号注释的代码,可以修改CPP的定义 加个参数 

 

ev.c,event.c

及为展开后的代码

测试可编译通过

附ev.c部分代码

struct ev_loop;
enum {EV_UNDEF = (int)0xFFFFFFFF,EV_NONE = 0x00,EV_READ = 0x01,EV_WRITE = 0x02,EV__IOFDSET = 0x80,EV_IO = EV_READ,EV_TIMER = 0x00000100,EV_TIMEOUT = EV_TIMER,EV_PERIODIC = 0x00000200,EV_SIGNAL = 0x00000400,EV_CHILD = 0x00000800,EV_STAT = 0x00001000,EV_IDLE = 0x00002000,EV_PREPARE = 0x00004000,EV_CHECK = 0x00008000,EV_EMBED = 0x00010000,EV_FORK = 0x00020000,EV_CLEANUP = 0x00040000,EV_ASYNC = 0x00080000,EV_CUSTOM = 0x01000000,EV_ERROR = (int)0x80000000
};
typedef struct ev_watcher
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_watcher *w, int revents);
} ev_watcher;typedef struct ev_watcher_list
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_watcher_list *w, int revents);struct ev_watcher_list *next;
} ev_watcher_list;typedef struct ev_watcher_time
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_watcher_time *w, int revents);ev_tstamp at;
} ev_watcher_time;typedef struct ev_io
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_io *w, int revents);struct ev_watcher_list *next;int fd;int events;
} ev_io;typedef struct ev_timer
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_timer *w, int revents);ev_tstamp at;ev_tstamp repeat;
} ev_timer;typedef struct ev_periodic
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_periodic *w, int revents); ev_tstamp at;ev_tstamp offset;ev_tstamp interval;ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) ;
} ev_periodic;typedef struct ev_signal
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_signal *w, int revents);struct ev_watcher_list *next;int signum;
} ev_signal;typedef struct ev_child
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_child *w, int revents);struct ev_watcher_list *next;int flags;int pid;int rpid;int rstatus;
} ev_child;typedef struct stat ev_statdata;typedef struct ev_stat
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_stat *w, int revents);struct ev_watcher_list *next;ev_timer timer;ev_tstamp interval;const char *path;ev_statdata prev;ev_statdata attr;int wd;
} ev_stat;typedef struct ev_idle
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_idle *w, int revents);
} ev_idle;typedef struct ev_prepare
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_prepare *w, int revents);
} ev_prepare;typedef struct ev_check
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_check *w, int revents);
} ev_check;typedef struct ev_fork
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_fork *w, int revents);
} ev_fork;typedef struct ev_cleanup
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_cleanup *w, int revents);
} ev_cleanup;typedef struct ev_embed
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_embed *w, int revents);struct ev_loop *other;ev_io io;ev_prepare prepare;ev_check check;ev_timer timer;ev_periodic periodic;ev_idle idle;ev_fork fork;ev_cleanup cleanup;} ev_embed;typedef struct ev_async
{int active; int pending; int priority; void *data; void (*cb)(struct ev_loop *loop, struct ev_async *w, int revents);sig_atomic_t volatile sent;
} ev_async;union ev_any_watcher
{struct ev_watcher w;struct ev_watcher_list wl;struct ev_io io;struct ev_timer timer;struct ev_periodic periodic;struct ev_signal signal;struct ev_child child;struct ev_stat stat;struct ev_idle idle;struct ev_prepare prepare;struct ev_check check;struct ev_fork fork;struct ev_cleanup cleanup;struct ev_embed embed;struct ev_async async;};enum {EVFLAG_AUTO = 0x00000000U,EVFLAG_NOENV = 0x01000000U,EVFLAG_FORKCHECK = 0x02000000U,EVFLAG_NOINOTIFY = 0x00100000U,EVFLAG_NOSIGFD = 0,EVFLAG_SIGNALFD = 0x00200000U,EVFLAG_NOSIGMASK = 0x00400000U
};enum {EVBACKEND_SELECT = 0x00000001U,EVBACKEND_POLL = 0x00000002U,EVBACKEND_EPOLL = 0x00000004U,EVBACKEND_KQUEUE = 0x00000008U,EVBACKEND_DEVPOLL = 0x00000010U,EVBACKEND_PORT = 0x00000020U,EVBACKEND_ALL = 0x0000003FU,EVBACKEND_MASK = 0x0000FFFFU
};extern int ev_version_major (void) ;
extern int ev_version_minor (void) ;extern unsigned int ev_supported_backends (void) ;
extern unsigned int ev_recommended_backends (void) ;
extern unsigned int ev_embeddable_backends (void) ;extern ev_tstamp ev_time (void) ;
extern void ev_sleep (ev_tstamp delay) ;extern void ev_set_allocator (void *(*cb)(void *ptr, long size) ) ;extern void ev_set_syserr_cb (void (*cb)(const char *msg) ) ;extern struct ev_loop *ev_default_loop (unsigned int flags ) ;static inline struct ev_loop *
ev_default_loop_uc_ (void)
{extern struct ev_loop *ev_default_loop_ptr;return ev_default_loop_ptr;
}static inline int
ev_is_default_loop (struct ev_loop *loop)
{return loop == ev_default_loop_uc_ ();
}extern struct ev_loop *ev_loop_new (unsigned int flags ) ;static inline void
idle_reify (struct ev_loop *loop)
{if (__builtin_expect ((!!(((loop)->idleall))),(0))){int pri;for (pri = ((((0x7f) & 4) ? +2 : 0) - (((0x7f) & 4) ? -2 : 0) + 1); pri--; ){if (((loop)->pendingcnt) [pri])break;if (((loop)->idlecnt) [pri]){queue_events (loop, (W *)((loop)->idles) [pri], ((loop)->idlecnt) [pri], EV_IDLE);break;}}}
}static inline void
timers_reify (struct ev_loop *loop)
{do { } while (0);if (((loop)->timercnt) && (((loop)->timers) [(4 - 1)]).at < ((loop)->mn_now)){do{ev_timer *w = (ev_timer *)(((loop)->timers) [(4 - 1)]).w;if (w->repeat){((WT)(w))->at += w->repeat;if (((WT)(w))->at < ((loop)->mn_now))((WT)(w))->at = ((loop)->mn_now);(__builtin_expect(!(("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.)), 0) ? __assert_rtn(__func__, "ev.c", 3207, "(\"libev: negative ev_timer repeat value found while processing timers\", w->repeat > 0.)") : (void)0);(((loop)->timers) [(4 - 1)]).at = (((loop)->timers) [(4 - 1)]).w->at;downheap (((loop)->timers), ((loop)->timercnt), (4 - 1));}elseev_timer_stop (loop, w);do { } while (0);feed_reverse (loop, (W)w);}while (((loop)->timercnt) && (((loop)->timers) [(4 - 1)]).at < ((loop)->mn_now));feed_reverse_done (loop, EV_TIMER);}
}static void __attribute__ ((__noinline__))
periodic_recalc (struct ev_loop *loop, ev_periodic *w)
{ev_tstamp interval = w->interval > 0.0001220703125 ? w->interval : 0.0001220703125;ev_tstamp at = w->offset + interval * floor ((((loop)->ev_rt_now) - w->offset) / interval);while (at <= ((loop)->ev_rt_now)){ev_tstamp nat = at + w->interval;if (__builtin_expect ((!!(nat == at)),(0))){at = ((loop)->ev_rt_now);break;}at = nat;}((WT)(w))->at = at;
}static inline void
periodics_reify (struct ev_loop *loop)
{do { } while (0);while (((loop)->periodiccnt) && (((loop)->periodics) [(4 - 1)]).at < ((loop)->ev_rt_now)){do{ev_periodic *w = (ev_periodic *)(((loop)->periodics) [(4 - 1)]).w;if (w->reschedule_cb){((WT)(w))->at = w->reschedule_cb (w, ((loop)->ev_rt_now));(__builtin_expect(!(("libev: ev_periodic reschedule callback returned time in the past", ((WT)(w))->at >= ((loop)->ev_rt_now))), 0) ? __assert_rtn(__func__, "ev.c", 3269, "(\"libev: ev_periodic reschedule callback returned time in the past\", ev_at (w) >= ev_rt_now)") : (void)0);(((loop)->periodics) [(4 - 1)]).at = (((loop)->periodics) [(4 - 1)]).w->at;downheap (((loop)->periodics), ((loop)->periodiccnt), (4 - 1));}else if (w->interval){periodic_recalc (loop, w);(((loop)->periodics) [(4 - 1)]).at = (((loop)->periodics) [(4 - 1)]).w->at;downheap (((loop)->periodics), ((loop)->periodiccnt), (4 - 1));}elseev_periodic_stop (loop, w);do { } while (0);feed_reverse (loop, (W)w);}while (((loop)->periodiccnt) && (((loop)->periodics) [(4 - 1)]).at < ((loop)->ev_rt_now));feed_reverse_done (loop, EV_PERIODIC);}
}static void __attribute__ ((__noinline__))
periodics_reschedule (struct ev_loop *loop)
{int i;for (i = (4 - 1); i < ((loop)->periodiccnt) + (4 - 1); ++i){ev_periodic *w = (ev_periodic *)(((loop)->periodics) [i]).w;if (w->reschedule_cb)((WT)(w))->at = w->reschedule_cb (w, ((loop)->ev_rt_now));else if (w->interval)periodic_recalc (loop, w);(((loop)->periodics) [i]).at = (((loop)->periodics) [i]).w->at;}reheap (((loop)->periodics), ((loop)->periodiccnt));
}static void __attribute__ ((__noinline__))
timers_reschedule (struct ev_loop *loop, ev_tstamp adjust)
{int i;for (i = 0; i < ((loop)->timercnt); ++i){ANHE *he = ((loop)->timers) + i + (4 - 1);(*he).w->at += adjust;(*he).at = (*he).w->at;}
}static inline void
time_update (struct ev_loop *loop, ev_tstamp max_block)
{{((loop)->ev_rt_now) = ev_time ();if (__builtin_expect ((!!(((loop)->mn_now) > ((loop)->ev_rt_now) || ((loop)->ev_rt_now) > ((loop)->mn_now) + max_block + 1.)),(0))){timers_reschedule (loop, ((loop)->ev_rt_now) - ((loop)->mn_now));periodics_reschedule (loop);}((loop)->mn_now) = ((loop)->ev_rt_now);}
}
View Code

还没看,以后可能也不会看了

转载于:https://www.cnblogs.com/zihunqingxin/p/5027350.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/458595.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

FreeRTOS高级篇7---FreeRTOS内存管理分析

原文&#xff1a;http://blog.csdn.net/zhzht19861011/article/details/51606068 内存管理对应用程序和操作系统来说都非常重要。现在很多的程序漏洞和运行崩溃都和内存分配使用错误有关。 FreeRTOS操作系统将内核与内存管理分开实现&#xff0c;操作系统内核仅规定了必要的内…

FreeRTOS学习笔记——互斥型信号量

来自&#xff1a;http://blog.csdn.net/xukai871105/article/details/43456985 0.前言 在嵌入式操作系统中互斥型信号量是任务间资源保护的重要手段。下面结合一个具体例子说明FreeRTOS中的互斥型信号量如何使用。 【相关博文】 【FreeRTOS STM32移植笔记】 【FreeRTOS学习笔记…

FreeRTOS系列第19篇---FreeRTOS信号量

来自&#xff1a;http://blog.csdn.net/zhzht19861011/article/details/50835613 本文介绍信号量的基础知识&#xff0c;详细源码分析见《FreeRTOS高级篇6---FreeRTOS信号量分析》 1.信号量简介 FreeRTOS的信号量包括二进制信号量、计数信号量、互斥信号量&#xff08;以后简称…

蓝牙HCI剖析(一)

来自&#xff1a;http://blog.csdn.net/xiaoxiaopengbo/article/details/51334257 一.HCI介绍 HCI提供了访问bluetooth control的统一接口&#xff0c;通俗来讲&#xff0c;就是定义了特定的格式来控制蓝牙芯片来做相应的动作&#xff08;比如inquiry,connect,disconnect&#…

ASP.NET状缓存Cache的应用-提高数据库读取速度

ASP.NET状缓存Cache的应用-提高数据库读取速度 原文:ASP.NET状缓存Cache的应用-提高数据库读取速度一、 Cache概述 既然缓存中的数据其实是来自数据库的&#xff0c;那么缓存中的数据如何和数据库进行同步呢&#xff1f;一般来说&#xff0c;缓存中应该存放改动不大或者对…

入门级----测试的执行、环境的搭建、每日构建、测试记录和跟踪、回归测试、测试总结和报告...

测试用例的准备&#xff0c;都是为了执行测试准备的。 测试环境的搭建 &#xff08;1&#xff09;测试数据&#xff1a;有些测试需要使用大批量的数据&#xff0c;例如容量测试、压力测试等。根据产品的具体测试要求&#xff0c;可能需要在数据库表插入大量的数据&#xff0c;准…

限制MySQL Binlog的传输速率

最近一台核心库备库完成恢复后打开slave&#xff0c;导致主库传送binlog&#xff0c;瞬间占满网络&#xff0c;触发故障。 为了做一些限制&#xff0c; 给mysql在发送binlog的函数(mysql_binlog_send)里每隔一段时间sleep一次&#xff0c; 增加了两个参数&#xff1a; master_s…

掌握 Ajax,第 2 部分: 使用 JavaScript 和 Ajax 发出异步请求

转http://www.ibm.com/developerworks/cn/xml/wa-ajaxintro2/ 掌握 Ajax&#xff0c;第 2 部分: 使用 JavaScript 和 Ajax 发出异步请求 在 Web 请求中使用 XMLHttpRequest 多数 Web 应用程序都使用请求/响应模型从服务器上获得完整的 HTML 页面。常常是点击一个按钮&#xff0…

Provisioning Services 7.8 入门系列教程之十一 通过版本控制自动更新虚拟磁盘

续Provisioning Services 7.8 入门系列教程之十 通过类自动更新虚拟磁盘从前两的两种更新方式可以看出&#xff0c;它们有一个共同的特点&#xff0c;即需要产生&#xff08;复制&#xff09;完成的虚拟磁盘副本&#xff0c;然后进行相关的升级操作。这两种方法在实际生产中&am…

登录失败时记住访问的地址

登录失败时记住访问的地址 使用spring MVC 访问时,在拦截器中记录访问的地址: Java代码 String path request.getRequestURI();//"/demo_channel_terminal/news/list" System.out.println("您无权访问:" path); //用于登录成功…

Tomcat - Maven plugin: 运行找不到webapp

2019独角兽企业重金招聘Python工程师标准>>> The tomcat7-maven-plugin allows running the current project as a Web application and additional <webapps> can be specified that will be simultaneously loaded into tomcat. My project is not a Web ap…

基于MQTT协议进行应用开发

来自&#xff1a;http://www.cnblogs.com/secondtononewe/p/6073089.html 官方协议有句如下的话来形容MQTT的设计思想&#xff1a; “It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth i…

SortedDictionaryTKey,TValue正序与反序排序及Dicttionary相关

SortedDictionary<TKey,TValue>能对字典排序 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace SortDictionary {class Program{static void Main(string[] args){TestDictionarySort();…

DOS窗口的编码页从UTF-8调回GBK

2019独角兽企业重金招聘Python工程师标准>>> 之前在DOS窗口操作MySQL数据库的时候&#xff0c;将编码页从GBK设置成了UTF-8&#xff0c;解决了在DOS窗口显示MySQL数据库中的表中的中文字符出现乱码的问题。但是除此之外&#xff0c;DOS窗口显示的其他中文字符都是乱…

UIBezierPath

学习UIBezierPath画图 笔者在写本篇文章之前&#xff0c;也没有系统学习过贝塞尔曲线&#xff0c;只是曾经某一次的需求需要使用到&#xff0c;才临时百度看了一看而且使用最基本的功能。现在总算有时间停下来好好研究研究这个神奇而伟大的贝塞尔先生&#xff01; 笔者在学习时…

系统架构设计理论与原则

一、无共享架构 1、无共享架构 无共享架构是一种分布式计算架构&#xff0c;这种架构中不存在集中存储的状态&#xff0c;系统中每个节点都是独立自治的&#xff0c;整个系统中没有资源竞争&#xff0c;这种架构具有非常强的扩张性&#xff0c;目前在web应用中被广泛使用。 无共…

VS2010 教程:创建一个 WPF 应用程序 (第一节)

来自&#xff1a;https://msdn.microsoft.com/zh-cn/library/ff629048.aspx [原文发表地址] VS2010 Tutorial: Build a WPF App (Step 1) [原文发表时间] Friday, May 22, 2009 8:00 AM 这篇文章里&#xff0c;我将使用VS2010 Beta 1创建一个WPF 应用程序。并且 我将展示这个产…

js 日期星期 带农历

Weekday代码 //得到当前日期如2009年6月19日 星期五 function getDate(){ var today new Date(); var x new Array("星期日", "星期一", "星期二","星期三","星期四", "星期五","星期六"…

iOS 推送

最近在研究ios的推送问题&#xff0c;遇到了一些问题&#xff0c;最终整理了一下。放在这里和大家分享APNS的推送机制首先我们看一下苹果官方给出的对ios推送机制的解释。如下图 Provider就是我们自己程序的后台服务器&#xff0c;APNS是Apple Push Notification Service的缩写…

iOS 加载本地html文件详细操作

webView的加载&#xff0c;如果是纯文本&#xff0c;有内部样式的话&#xff0c;简单的加载请求就可以了。如下: 这种加载简单直接&#xff0c;易操作。 如果需要加载images&#xff0c;css文件 需要把xcode的项目请求路径的位置告诉webView.代码如下&#xff1a; 这样html文件…