Platform.cpp
Go to the documentation of this file.
00001 /*
00002  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
00003  *
00004  * Copyright 2007-2012 VTT Technical Research Centre of Finland
00005  *
00006  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
00007  *          <http://www.vtt.fi/multimedia/alvar.html>
00008  *
00009  * ALVAR is free software; you can redistribute it and/or modify it under the
00010  * terms of the GNU Lesser General Public License as published by the Free
00011  * Software Foundation; either version 2.1 of the License, or (at your option)
00012  * any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with ALVAR; if not, see
00021  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
00022  */
00023 
00024 #include "Platform.h"
00025 
00026 #include <stdio.h>
00027 #include <stdarg.h>
00028 #include <string.h>
00029 #include <stdlib.h>
00030 #ifdef WIN32
00031     #include <windows.h>
00032 #else
00033     #include <time.h>
00034 #endif
00035 
00036 namespace alvar {
00037 
00038 void errorAtLine(int status, int error, const char *filename,
00039                  unsigned int line, const char *format, ...)
00040 {
00041     fflush(stdout);
00042     if (filename) {
00043         fprintf(stderr, "%s:%d: ", filename, line);
00044     }
00045     if (format) {
00046         va_list args;
00047         va_start(args, format);
00048         vfprintf(stderr, format, args);
00049         va_end(args);
00050     }
00051     if (error) {
00052         fprintf(stderr, ": %s", strerror(error));
00053     }
00054     fprintf(stderr, "\n");
00055     fflush(stderr);
00056     if (status) {
00057         exit(status);
00058     }
00059 }
00060 
00061 void sleep(unsigned long milliseconds)
00062 {
00063     #ifdef WIN32
00064         Sleep(milliseconds);
00065     #else
00066         struct timespec t;
00067         t.tv_sec = 0;
00068         t.tv_nsec = 1000 * 1000 * milliseconds;
00069         nanosleep(&t, NULL);
00070     #endif
00071 }
00072 
00073 } // namespace alvar


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Thu Jun 6 2019 21:12:54