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.pswp.cn/news/458595.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/458595.shtml
英文地址,請注明出處:http://en.pswp.cn/news/458595.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

FreeRTOS高級篇7---FreeRTOS內存管理分析

原文&#xff1a;http://blog.csdn.net/zhzht19861011/article/details/51606068 內存管理對應用程序和操作系統來說都非常重要。現在很多的程序漏洞和運行崩潰都和內存分配使用錯誤有關。 FreeRTOS操作系統將內核與內存管理分開實現&#xff0c;操作系統內核僅規定了必要的內…

筆試題

1.是不是一個父類寫了一個virtual 函數&#xff0c;如果子類覆蓋它的函數不加virtual ,也能實現多態? virtual修飾符會被隱形繼承的。private 也被集成&#xff0c;只事派生類沒有訪問權限而已。virtual可加可不加。子類的空間里有父類的所有變量(static除外)。同一個函數只存…

FreeRTOS學習筆記——互斥型信號量

來自&#xff1a;http://blog.csdn.net/xukai871105/article/details/43456985 0.前言 在嵌入式操作系統中互斥型信號量是任務間資源保護的重要手段。下面結合一個具體例子說明FreeRTOS中的互斥型信號量如何使用。 【相關博文】 【FreeRTOS STM32移植筆記】 【FreeRTOS學習筆記…

JSP動態網站環境搭建應用中的詳細步驟(Tomcat和Apache/IIS的整合)

鏈接地址&#xff1a;http://www.cnblogs.com/dartagnan/archive/2011/03/25/2003426.html JSP動態網站環境搭建應用中的詳細步驟(Tomcat和Apache/IIS的整合)sun推出的JSP&#xff08;Java Server Pages&#xff09;是一種執行于服務器端的動態網頁開發技術&#xff0c;它基于J…

關于JS獲取select值的兩種實現方法

前幾天發了一篇關于javascript獲取select值的方法&#xff0c;后來發現有另一種實現方法&#xff0c;所以就都發出來比較一下&#xff1a; 方法一&#xff1a;通過獲取option標簽的value值來確定&#xff1a; <!DOCTYPE html> <html> <head><meta charset…

c語言題庫1

1. 用預處理指令#define 聲明一個常數&#xff0c;用以表明1年中有多少秒&#xff08;忽略閏年問題&#xff09; #define time (365*24*60*60) #define SECONDS_PER_YEAR (60 * 60 * 24 * 365) 2. 寫一個“標準”宏MIN&#xff0c;這個宏輸入兩個參數并返回較小的一個。 #di…

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

來自&#xff1a;http://blog.csdn.net/zhzht19861011/article/details/50835613 本文介紹信號量的基礎知識&#xff0c;詳細源碼分析見《FreeRTOS高級篇6---FreeRTOS信號量分析》 1.信號量簡介 FreeRTOS的信號量包括二進制信號量、計數信號量、互斥信號量&#xff08;以后簡稱…

mysql語法替換字符串

UPDATE ht_business_task SET url REPLACE ( url, &amp;, & )轉載于:https://www.cnblogs.com/lz20150121/p/5030739.html

POJ1274 The Perfect Stall(二分圖)

題意&#xff1a; 一些奶牛只有在特定的圍欄中才能產奶&#xff0c;要求合理安排使能產奶的奶牛數達到最大。 要點&#xff1a; 二分圖裸題&#xff0c;最近剛學了二分圖&#xff0c;看下面的參考博客&#xff0c;寫的比較好&#xff1a; 參考博客&#xff1a;匈牙利算法 15479…

藍牙HCI剖析(一)

來自&#xff1a;http://blog.csdn.net/xiaoxiaopengbo/article/details/51334257 一.HCI介紹 HCI提供了訪問bluetooth control的統一接口&#xff0c;通俗來講&#xff0c;就是定義了特定的格式來控制藍牙芯片來做相應的動作&#xff08;比如inquiry,connect,disconnect&#…

c語言題庫2

96. struct name1{ char str; short x; int num; } struct name2{ char str;0 1 2 3 int num; 4 5 6 7 short x; 8 9 10 11 } sizeof(struct name1)? sizeof(struct name2)? 8、12 97. 讀文件file1.txt的內容&#xff08;例如&#xff09;&#xff1a; 12 34 56 …

ASP.NET狀緩存Cache的應用-提高數據庫讀取速度

ASP.NET狀緩存Cache的應用-提高數據庫讀取速度 原文:ASP.NET狀緩存Cache的應用-提高數據庫讀取速度一、 Cache概述 既然緩存中的數據其實是來自數據庫的&#xff0c;那么緩存中的數據如何和數據庫進行同步呢&#xff1f;一般來說&#xff0c;緩存中應該存放改動不大或者對…

2016年學習Linux決心書(老男孩教育在線課程班第二期)

我經過這4-5個月的學習后&#xff0c;我一定要達到月薪20&#xff2b;&#xff0c;為了達到這個目標我要付出如下10大行動&#xff1a;1.提前預習上課內容2.上課認真聽講&#xff0c;做好上課筆記3.課后認真做總結&#xff0c;完善筆記5.反復做實驗&#xff0c;并寫實驗文檔6.學…

WPF XAML 從零開始認識XAML

來自&#xff1a;http://blog.csdn.net/aoshilang2249/article/details/44158403 剖析最簡單的XMAL代碼: [html] view plaincopy <Window x:Class"MyFirstApplication.MainWindow" xmlns"http://schemas.microsoft.com/winfx/2006/xaml/presentati…

c語言題庫3

143. 枚舉元素本身由系統定義了一個表示序號的數值&#xff0c;從0 開始順序定義為0&#xff0c;1&#xff0c;2…。如在weekday中&#xff0c;sun值為0&#xff0c;mon值為1&#xff0c; …,sat值為6。 main(){  enum weekday  {   sun,mon,tue,wed,thu,fri,sat  } a,b…

入門級----測試的執行、環境的搭建、每日構建、測試記錄和跟蹤、回歸測試、測試總結和報告...

測試用例的準備&#xff0c;都是為了執行測試準備的。 測試環境的搭建 &#xff08;1&#xff09;測試數據&#xff1a;有些測試需要使用大批量的數據&#xff0c;例如容量測試、壓力測試等。根據產品的具體測試要求&#xff0c;可能需要在數據庫表插入大量的數據&#xff0c;準…

MFC讀取配置文件GetPrivateProfileString

VC中 3 個主要 寫入/讀取配置文件ini的函數&#xff1a;bool WritePrivateProfileString(LPCTSTR lpAppName,LPCTSTR lpKeyName,LPCTSTR lpString,LPCTSTR lpFileName);寫入.ini文件&#xff1b;DWORDGetPrivateProfileString(LPCTSTR lpAppName,LPCTSTR lpKeyName,LPCTSTR lpD…

UESTC 250 windy數 數位dp

題目鏈接 1 #include<bits/stdc.h>2 using namespace std;3 #define mem1(a) memset(a, -1, sizeof(a))4 #define ll long long5 int dp[20][20], digit[20], len;6 ll dfs(int len, int pre, bool fp, bool first) { //first表示前面的數是否全部為0&#xff0c; pr…

c語言面試題大全

C語言面試題大匯總 4. static有什么用途&#xff1f;&#xff08;請至少說明兩種&#xff09; 1.限制變量的作用域(DL:使其只在定義的當前文件中起作用&#xff0c;static是只能由與變量在同一個文件中定義的程序存取的全局變量。也就是說使全局變量成為文件的私有變量&#…

WindowsAPI詳解——GetCurrentDirectory 獲得程序當前目錄

每個Windows程序都有一個自己的當前目錄&#xff0c;默認是程序exe文件所在的目錄。系統在給程序加載動態鏈接庫文件(DLL)時先在程序當前目錄里查找要加載的DLL&#xff0c;如果在此目錄下沒有找到系統便會去Windows目錄下查找。在這兒我們主要將如何獲得程序的當前目錄&#x…