1 # Check for (mingw)win32 POSIX replacements. -*- Autoconf -*-
3 # Copyright 2003,2004,2005 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
25 AC_REQUIRE([AC_HEADER_TIME])
26 AC_CHECK_HEADERS([sys/types.h fcntl.h io.h])
27 AC_CHECK_HEADERS([windows.h])
28 AC_CHECK_HEADERS([winioctl.h winbase.h], [], [], [
34 AC_CHECK_FUNCS([getopt usleep gettimeofday nanosleep rand srand random srandom sleep sigaction])
35 AC_CHECK_TYPES([struct timezone, struct timespec, ssize_t],[],[],[
37 # include <sys/types.h>
39 #if TIME_WITH_SYS_TIME
40 # include <sys/time.h>
44 # include <sys/time.h>
51 dnl Checks for replacements
52 AC_REPLACE_FUNCS([getopt usleep gettimeofday])
55 AC_MSG_CHECKING(for Sleep)
56 AC_TRY_LINK([ #include <windows.h>
59 [AC_DEFINE(HAVE_SSLEEP,1,[Define to 1 if you have win32 Sleep])
64 dnl Under Win32, mkdir prototype in io.h has only one arg
65 AC_MSG_CHECKING(whether mkdir accepts only one arg)
66 AC_TRY_COMPILE([#include <sys/types.h>
68 #include <fcntl.h>], [
70 ], [ AC_MSG_RESULT(yes)
71 AC_DEFINE(MKDIR_TAKES_ONE_ARG,[],[Define if mkdir accepts only one arg]) ],
77 /* Define missing prototypes, implemented in replacement lib */
83 int getopt (int argc, char * const argv[], const char * optstring);
85 extern int optind, opterr, optopt;
89 int usleep(unsigned long usec); /* SUSv2 */
92 #ifndef HAVE_NANOSLEEP
93 #ifndef HAVE_STRUCT_TIMESPEC
95 # include <sys/types.h> /* need time_t */
102 static inline int nanosleep(const struct timespec *req, struct timespec *rem) { return usleep(req->tv_sec*1000000+req->tv_nsec/1000); }
105 #if defined(HAVE_SSLEEP) && !defined(HAVE_SLEEP)
106 #ifdef HAVE_WINBASE_H
110 /* TODO: what about SleepEx? */
111 static inline unsigned int sleep (unsigned int nb_sec) { Sleep(nb_sec*1000); return 0; }
114 #ifndef HAVE_GETTIMEOFDAY
115 #ifdef HAVE_SYS_TIME_H
116 #include <sys/time.h>
118 #ifndef HAVE_STRUCT_TIMEZONE
124 int gettimeofday(struct timeval *tv, struct timezone *tz);
127 #if !defined(HAVE_RANDOM) && defined(HAVE_RAND)
129 static inline long int random (void) { return rand(); }
132 #if !defined(HAVE_SRANDOM) && defined(HAVE_SRAND)
133 static inline void srandom (unsigned int seed) { srand(seed); }
137 typedef size_t ssize_t;