\doxysection{select.\+h}
\label{select_8h_source}\index{include/osmocom/core/select.h@{include/osmocom/core/select.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{5 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <time.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <signal.h>}}
\DoxyCodeLine{11 }
\DoxyCodeLine{17 \textcolor{preprocessor}{\#define OSMO\_FD\_READ    0x0001}}
\DoxyCodeLine{19 \textcolor{preprocessor}{\#define OSMO\_FD\_WRITE   0x0002}}
\DoxyCodeLine{21 \textcolor{preprocessor}{\#define OSMO\_FD\_EXCEPT  0x0004}}
\DoxyCodeLine{23 \textcolor{preprocessor}{\#define OSMO\_FD\_MASK    0xFFFF}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{comment}{/* legacy naming dating back to early OpenBSC / bsc\_hack of 2008 */}}
\DoxyCodeLine{26 \textcolor{preprocessor}{\#define BSC\_FD\_READ     OSMO\_FD\_READ}}
\DoxyCodeLine{27 \textcolor{preprocessor}{\#define BSC\_FD\_WRITE    OSMO\_FD\_WRITE}}
\DoxyCodeLine{28 \textcolor{preprocessor}{\#define BSC\_FD\_EXCEPT   OSMO\_FD\_EXCEPT}}
\DoxyCodeLine{29 }
\DoxyCodeLine{31 \textcolor{keyword}{struct }osmo\_fd \{}
\DoxyCodeLine{33         \textcolor{keyword}{struct }llist\_head list;   }
\DoxyCodeLine{35         \textcolor{keywordtype}{int} fd;}
\DoxyCodeLine{38         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} when;}
\DoxyCodeLine{41         int (*cb)(\textcolor{keyword}{struct }osmo\_fd *fd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} what);}
\DoxyCodeLine{43         \textcolor{keywordtype}{void} *data;}
\DoxyCodeLine{45         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} priv\_nr;}
\DoxyCodeLine{46 \};}
\DoxyCodeLine{47 }
\DoxyCodeLine{48 \textcolor{keywordtype}{void} osmo\_fd\_setup(\textcolor{keyword}{struct} osmo\_fd *ofd, \textcolor{keywordtype}{int} fd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} when,}
\DoxyCodeLine{49                    \textcolor{keywordtype}{int} (*cb)(\textcolor{keyword}{struct} osmo\_fd *fd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} what),}
\DoxyCodeLine{50                    \textcolor{keywordtype}{void} *data, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} priv\_nr);}
\DoxyCodeLine{51 }
\DoxyCodeLine{52 \textcolor{keywordtype}{void} osmo\_fd\_update\_when(\textcolor{keyword}{struct} osmo\_fd *ofd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} when\_mask, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} when);}
\DoxyCodeLine{53 }
\DoxyCodeLine{54 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} osmo\_fd\_read\_enable(\textcolor{keyword}{struct} osmo\_fd *ofd) \{}
\DoxyCodeLine{55         osmo\_fd\_update\_when(ofd, OSMO\_FD\_MASK, OSMO\_FD\_READ);}
\DoxyCodeLine{56 \}}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} osmo\_fd\_read\_disable(\textcolor{keyword}{struct} osmo\_fd *ofd) \{}
\DoxyCodeLine{59         osmo\_fd\_update\_when(ofd, \string~OSMO\_FD\_READ, 0);}
\DoxyCodeLine{60 \}}
\DoxyCodeLine{61 }
\DoxyCodeLine{62 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} osmo\_fd\_write\_enable(\textcolor{keyword}{struct} osmo\_fd *ofd) \{}
\DoxyCodeLine{63         osmo\_fd\_update\_when(ofd, OSMO\_FD\_MASK, OSMO\_FD\_WRITE);}
\DoxyCodeLine{64 \}}
\DoxyCodeLine{65 }
\DoxyCodeLine{66 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} osmo\_fd\_write\_disable(\textcolor{keyword}{struct} osmo\_fd *ofd) \{}
\DoxyCodeLine{67         osmo\_fd\_update\_when(ofd, \string~OSMO\_FD\_WRITE, 0);}
\DoxyCodeLine{68 \}}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{keywordtype}{bool} osmo\_fd\_is\_registered(\textcolor{keyword}{struct} osmo\_fd *fd);}
\DoxyCodeLine{71 \textcolor{keywordtype}{int} osmo\_fd\_register(\textcolor{keyword}{struct} osmo\_fd *fd);}
\DoxyCodeLine{72 \textcolor{keywordtype}{void} osmo\_fd\_unregister(\textcolor{keyword}{struct} osmo\_fd *fd);}
\DoxyCodeLine{73 \textcolor{keywordtype}{void} osmo\_fd\_close(\textcolor{keyword}{struct} osmo\_fd *fd);}
\DoxyCodeLine{74 \textcolor{keywordtype}{int} osmo\_select\_main(\textcolor{keywordtype}{int} polling);}
\DoxyCodeLine{75 \textcolor{keywordtype}{int} osmo\_select\_main\_ctx(\textcolor{keywordtype}{int} polling);}
\DoxyCodeLine{76 \textcolor{keywordtype}{void} osmo\_select\_init(\textcolor{keywordtype}{void});}
\DoxyCodeLine{77 }
\DoxyCodeLine{78 \textcolor{keyword}{struct }osmo\_fd *osmo\_fd\_get\_by\_fd(\textcolor{keywordtype}{int} fd);}
\DoxyCodeLine{79 }
\DoxyCodeLine{80 \textcolor{comment}{/*}}
\DoxyCodeLine{81 \textcolor{comment}{ * foreign event loop integration}}
\DoxyCodeLine{82 \textcolor{comment}{ */}}
\DoxyCodeLine{83 \textcolor{keywordtype}{int} osmo\_fd\_fill\_fds(\textcolor{keywordtype}{void} *readset, \textcolor{keywordtype}{void} *writeset, \textcolor{keywordtype}{void} *exceptset);}
\DoxyCodeLine{84 \textcolor{keywordtype}{int} osmo\_fd\_disp\_fds(\textcolor{keywordtype}{void} *readset, \textcolor{keywordtype}{void} *writeset, \textcolor{keywordtype}{void} *exceptset);}
\DoxyCodeLine{85 }
\DoxyCodeLine{86 \textcolor{comment}{/* timerfd integration */}}
\DoxyCodeLine{87 \textcolor{keywordtype}{int} osmo\_timerfd\_disable(\textcolor{keyword}{struct} osmo\_fd *ofd);}
\DoxyCodeLine{88 \textcolor{keywordtype}{int} osmo\_timerfd\_schedule(\textcolor{keyword}{struct} osmo\_fd *ofd, \textcolor{keyword}{const} \textcolor{keyword}{struct} timespec *first,}
\DoxyCodeLine{89                           \textcolor{keyword}{const} \textcolor{keyword}{struct} timespec *interval);}
\DoxyCodeLine{90 \textcolor{keywordtype}{int} osmo\_timerfd\_setup(\textcolor{keyword}{struct} osmo\_fd *ofd, \textcolor{keywordtype}{int} (*cb)(\textcolor{keyword}{struct} osmo\_fd *, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int}), \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{91 }
\DoxyCodeLine{92 \textcolor{comment}{/* signalfd integration */}}
\DoxyCodeLine{93 \textcolor{keyword}{struct }osmo\_signalfd;}
\DoxyCodeLine{94 \textcolor{keyword}{struct }signalfd\_siginfo;}
\DoxyCodeLine{95 }
\DoxyCodeLine{96 \textcolor{keyword}{typedef} \textcolor{keywordtype}{void} osmo\_signalfd\_cb(\textcolor{keyword}{struct} osmo\_signalfd *osfd, \textcolor{keyword}{const} \textcolor{keyword}{struct} signalfd\_siginfo *fdsi);}
\DoxyCodeLine{97 }
\DoxyCodeLine{98 \textcolor{keyword}{struct }osmo\_signalfd \{}
\DoxyCodeLine{99         \textcolor{keyword}{struct }osmo\_fd ofd;}
\DoxyCodeLine{100         sigset\_t sigset;}
\DoxyCodeLine{101         osmo\_signalfd\_cb *cb;}
\DoxyCodeLine{102         \textcolor{keywordtype}{void} *data;}
\DoxyCodeLine{103 \};}
\DoxyCodeLine{104 }
\DoxyCodeLine{105 \textcolor{keyword}{struct }osmo\_signalfd *}
\DoxyCodeLine{106 osmo\_signalfd\_setup(\textcolor{keywordtype}{void} *ctx, sigset\_t set, osmo\_signalfd\_cb *cb, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{107 }
\DoxyCodeLine{108 \textcolor{keywordtype}{void} osmo\_select\_shutdown\_request(\textcolor{keywordtype}{void});}
\DoxyCodeLine{109 \textcolor{keywordtype}{int} osmo\_select\_shutdown\_requested(\textcolor{keywordtype}{void});}
\DoxyCodeLine{110 \textcolor{keywordtype}{bool} osmo\_select\_shutdown\_done(\textcolor{keywordtype}{void});}
\DoxyCodeLine{111 }

\end{DoxyCode}
