1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

portability simplification with scmsigs.c and alarm

* configure.ac (alarm): Check for decl.
* libguile/scmsigs.c: Reorder includes to put system includes first.
  Fixes include order on mingw.  Remove #define for alarm, as we will
  use HAVE_DECL_ALARM.  Remove #defines for sleep and usleep, as they
  are not used.
  (scm_alarm): Only define if HAVE_DECL_ALARM.
This commit is contained in:
Andy Wingo 2013-03-09 22:25:35 +01:00
parent 4fd38267bc
commit cdd125e8d4
2 changed files with 16 additions and 20 deletions

View file

@ -919,6 +919,8 @@ AC_DEFUN([GUILE_FUNC_DECLARED], [
GUILE_FUNC_DECLARED(sleep, unistd.h)
GUILE_FUNC_DECLARED(usleep, unistd.h)
AC_CHECK_DECLS([alarm])
AC_CHECK_DECLS([strptime],,,
[#define _GNU_SOURCE /* ask glibc to give strptime prototype */
#include <time.h>])

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2006, 2007, 2008, 2009, 2011, 2013 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@ -28,17 +28,6 @@
#include <stdio.h>
#include <errno.h>
#include "libguile/_scm.h"
#include "libguile/async.h"
#include "libguile/eval.h"
#include "libguile/root.h"
#include "libguile/vectors.h"
#include "libguile/threads.h"
#include "libguile/validate.h"
#include "libguile/scmsigs.h"
#ifdef HAVE_PROCESS_H
#include <process.h> /* for mingw */
#endif
@ -51,16 +40,19 @@
#include <sys/time.h>
#endif
#ifdef __MINGW32__
#include <windows.h>
#define alarm(sec) (0)
/* This weird comma expression is because Sleep is void under Windows. */
#define sleep(sec) (Sleep ((sec) * 1000), 0)
#define usleep(usec) (Sleep ((usec) / 1000), 0)
#endif
#include <full-write.h>
#include "libguile/_scm.h"
#include "libguile/async.h"
#include "libguile/eval.h"
#include "libguile/root.h"
#include "libguile/vectors.h"
#include "libguile/threads.h"
#include "libguile/validate.h"
#include "libguile/scmsigs.h"
@ -499,6 +491,7 @@ SCM_DEFINE (scm_restore_signals, "restore-signals", 0, 0, 0,
}
#undef FUNC_NAME
#if defined HAVE_ALARM && HAVE_DECL_ALARM
SCM_DEFINE (scm_alarm, "alarm", 1, 0, 0,
(SCM i),
"Set a timer to raise a @code{SIGALRM} signal after the specified\n"
@ -514,6 +507,7 @@ SCM_DEFINE (scm_alarm, "alarm", 1, 0, 0,
return scm_from_uint (alarm (scm_to_uint (i)));
}
#undef FUNC_NAME
#endif /* HAVE_ALARM */
#ifdef HAVE_SETITIMER
SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0,