root/ossie/branches/ossie-0.6.0/ossie/include/ossie/portability.h @ 2696

Revision 2696, 1.6 KB (checked in by phelps, 6 years ago)

Manually apply r2587 from trunk.

  • Property svn:eol-style set to native
Line 
1/*******************************************************************************
2
3Copyright 2005-2006, Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE Parser.
6
7OSSIE Parser is free software; you can redistribute it and/or modify
8it under the terms of the Lesser GNU General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or
10(at your option) any later version.
11
12OSSIE Parser is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15Lesser GNU General Public License for more details.
16
17You should have received a copy of the Lesser GNU General Public License
18along with OSSIE Parser; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21*/
22
23#ifndef PORTABILITY_H
24#define PORTABILITY_H
25
26#ifdef HAVE_UNISTD_H
27#include <unistd.h>
28#endif
29#ifdef HAVE_TIME_H
30#include <time.h>
31#endif
32
33namespace ossieSupport {
34  /**
35     Sleep for integer number of seconds.
36  */
37  inline unsigned int sleep(unsigned int seconds)
38    {
39#ifdef HAVE_UNISTD_H
40      return ::sleep(seconds);
41#endif
42#ifdef MSdot_NET
43      Sleep(seconds*1000);
44#endif
45    }
46
47  /**
48     Nano-second resolution sleep.
49  */
50  inline int nsleep(unsigned long seconds, unsigned long nano_seconds) {
51#ifdef HAVE_TIME_H
52    struct timespec t, rem;
53
54    t.tv_sec = seconds;
55    t.tv_nsec = nano_seconds;
56
57    int result = nanosleep(&t, &rem);
58
59    return result;
60#endif
61  }
62}
63
64#endif
Note: See TracBrowser for help on using the browser.