* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#include "config.h"
+
+/* gwakeup.c is special -- GIO and some test cases include it. As such,
+ * it cannot include other glib headers without triggering the single
+ * includes warnings. We have to manually include its dependencies here
+ * (and at all other use sites).
+ */
+#ifdef GLIB_COMPILATION
+#include "gtypes.h"
+#include "gpoll.h"
+#else
+#include <glib.h>
+#endif
+
#include "gwakeup.h"
-/**
+/*< private >
* SECTION:gwakeup
* @title: GWakeup
* @short_description: portable cross-thread event signal mechanism
#ifdef _WIN32
#include <windows.h>
+
+#ifdef GLIB_COMPILATION
#include "gmessages.h"
#include "giochannel.h"
#include "gwin32.h"
+#endif
GWakeup *
g_wakeup_new (void)
/* try eventfd first, if we think we can */
#if defined (HAVE_EVENTFD)
+#ifndef TEST_EVENTFD_FALLBACK
wakeup->fds[0] = eventfd (0, EFD_CLOEXEC | EFD_NONBLOCK);
+#else
+ wakeup->fds[0] = -1;
+#endif
if (wakeup->fds[0] != -1)
{
void
g_wakeup_signal (GWakeup *wakeup)
{
- guint64 one = 1;
+ int res;
if (wakeup->fds[1] == -1)
- write (wakeup->fds[0], &one, sizeof one);
+ {
+ guint64 one = 1;
+
+ /* eventfd() case. It requires a 64-bit counter increment value to be
+ * written. */
+ do
+ res = write (wakeup->fds[0], &one, sizeof one);
+ while (G_UNLIKELY (res == -1 && errno == EINTR));
+ }
else
- write (wakeup->fds[1], &one, 1);
+ {
+ guint8 one = 1;
+
+ /* Non-eventfd() case. Only a single byte needs to be written, and it can
+ * have an arbitrary value. */
+ do
+ res = write (wakeup->fds[1], &one, sizeof one);
+ while (G_UNLIKELY (res == -1 && errno == EINTR));
+ }
}
/**